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.
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 Media Stream (e.g. Webcam & Screen share). Client application can listen on this event to subscribe 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)
)
}
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)
)
}
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
)
}
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"
)
}
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"
)
}
Last updated
Was this helpful?