WebRTC.ai
  • Introduction
  • Get Started
  • Authorisation
  • Events
  • Error Codes
Powered by GitBook
On this page
  • New publisher joining the session:
  • Existing publisher left the session:
  • Session reconnecting:
  • Session reconnected:
  • Session disconnected:

Was this helpful?

Events

Once the client application has successfully initiated a connection, the connector object would emit different events to indicate various activities in the live session.

PreviousAuthorisationNextError Codes

Last updated 3 years ago

Was this helpful?

New publisher joining the session:

WebRTCai.events.publisher Whenever a new publisher successfully starts publishing a new stream this event would be fired. A separate event would be fired for each (e.g. Webcam & Screen share). Client application can listen on this event to to this new publisher.

connector.on(WebRTCai.events.publisher, (data) =>{
    console.log(
        data.user_id, // user id of the new publisher joining the session, as provided by your client application 
        data.type,    // 'video' for webcam, 'screen' for screen sharing
        date.id,        // a uniue identifier (real-time)
    )
}

Please note that this event is not fired on successful , rather on successful method of that instance of SDK.

Existing publisher left the session:

WebRTCai.events.publisherLeft Whenever an existing publisher stops publishing their media stream this event would be fired. Client application can listen on this event to detach the stream.

connector.on(WebRTCai.events.publisherLeft, (data) =>{
    console.log(
        data.user_id, // the uid provided by your client application, when this publisher initiated the connection
        data.type,    // 'video' for webcam, 'screen' for screen sharing
        date.id,        // a uniue identifier (real-time)
    )
}

Please note the SDK would pause the video element to which this Media Stream is connected before firing the event.

Session reconnecting:

WebRTCai.events.reconnecting Whenever the connection to the server breaks down, this event would be fired. The SDK would try to re-establish the connection periodically with increasing time delays.

connector.on(WebRTCai.events.reconnecting, (data) =>{
    console.log(
        data.reconnectTimeout, // time in milli-seconds after which the SDK would try to re-establish the connection
    )
}

Please note the SDK would pause all the video elements while the session is in this state. and would play them back once the session is reconnected

Session reconnected:

WebRTCai.events.reconnected Whenever the connection to the server breaks down and re-establishes, this event would be fired. The SDK would try to re-create the state of the session before it was disconnected.

connector.on(WebRTCai.events.reconnecting, (data) =>{
    console.log(
        "We are back in business"
    )
}

SDK would first establish the connection to server, then subscribe to all the publishers that were present in the session before the disconnection and then try to publish its own feeds (if there were any). After all this process the reconnected event would be fired.

Session disconnected:

WebRTCai.events.disconected Whenever the client application initiates a disconnect method on the sessionObject.

connector.on(WebRTCai.events.reconnecting, (data) =>{
    console.log(
        "No more conversations"
    )
}

This event would not be fired in case of network failure, SDK would keep trying to connect to the server with increasing time gap.

Media Stream
subscribe
init_connection
publish