Events
useEventListener(eventName: string , callback: () ⇒ void)
// Usage:
useEventListener("event-name", () => {
// Write your logic here
console.log("event-name")
})
// Example:
useEventListener("lobby:joined", () => {
// Write your logic here
console.log("lobby:joined")
})
We provide a robust event system that allows you to listen for specific events and execute callback functions based on them. Below is a list of events available within the SDK:
Event Name | Description |
---|---|
app:initialized | triggers when the app is successfully initialized after calling @initialize() method |
lobby:failed | triggers when @joinLobby() method fails,reason for failing can be found in @error |
lobby:metadata | triggers when @joinLobby() method succeeds and presents you with the metadata of peers inside the room |
app:cam-on | triggers when Camera has successfully loaded after calling @fetchVideoStream() |
app:cam-off | triggers when Video Stream has successfully stopped after calling @stopVideoStream() |
app:mic-on | triggers when Mic has successfully loaded after calling @fetchAudioStream() |
app:mic-off | triggers when Audio Stream has successfully stopped after calling @stopAudioStream() |
room:joined | triggers when room is successfully joined after calling the @joinRoom() method |
room:failed | triggers when @joinRoom() method fails, reason for failing can be found in @error |
room:cam-produce-start | triggers when the user starts producing cam stream in the room |
room:cam-produce-stop | triggers when the user stops producing cam stream in the room |
room:mic-produce-start | triggers when the user starts producing mic stream in the room |
room:mic-produce-stop | triggers when the user stops producing mic stream in the room |
room:me-role-update | triggers when the current user role is updated in the room |
room:me-name-update | triggers when the current user name is updated in the room |
room:me-left | triggers when the current user leaves the room |
room:peer-joined | triggers when a new participant joins the room, the @peerIds[] array gets updated when this happens |
room:peer-left | triggers when a participant leaves the room, the @peerIds[] array gets updated when this happens |
room:peer-produce-start | triggers when peer in the room starts producing mic or cam stream |
room:peer-produce-stop | triggers when peer in the room stops producing mic or cam stream |
room:peer-role-update | triggers when peer's role is updated in the room |
room:peer-name-update | triggers when peer's name is updated in the room |
room:peer-kicked | triggers when peer is kicked out from the room |
room:peer-avatar-update | triggers when peer updates it's avatar in the room |
room:data-received | trigger when data is received from peer in the room, @data will contain the data received |
room:recording-started | triggers when a recording has started in the room, @inProgress will turn to true |
room:recording-stopped | triggers when a recording has stopped in the room, @inProgress will turn to false |
room:recording-data | triggers when a recording has stopped and the data is available, this event will return the recording data |
room:livestream-started | triggers when a livestream has started in the room, @inProgress will turn to true |
room:livestream-stopped | triggers when the livestream has started in the room, @inProgress will turn to false |
App states
The following are the four app states that your app can be in at any given point:
- IDLE: The client has not been initialized yet, so no methods can be invoked at this stage.
- INIT: The client has been initialized and is ready for you to invoke the joinLobby() method.
- LOBBY: The user has joined the lobby and is ready to join a room or perform other lobby-related actions.
- ROOM: The user has entered the meeting room and is ready has access to meeting-room controls.