Detecting when you have disconnected

You setup an EventListner to execute a function if a user is disconnected from a session.

For example, the function can notify the user whenever they loose connection and are no longer connected to the session.

When your client disconnects from a session, the OTSession component dispatches a sessionDisconnected event:

<OTSession
  applicationId="your-api-key"
  sessionId="your-session-id"
  token="your-session-token"
  eventHandlers={{
    sessionDisconnected: event => {
        console.log('disconnected', event);
      },
    connected: event => {
      console.log('subscriber connected', event);
    },
  }}
>
  <OTPublisher style={{ width: 100, height: 100 }}/>
  <OTSubscriber style={{ width: 100, height: 100 }} />
</OTSession>