Callback Listeners
Add Callback Event Listeners#
Add all following callback methods while initializing the SDK. Callback listeners are functions that will be called whenever the specified event happens.
Note: Callback Listener name should be the same as described below.
Helper Object#
For getting the logged-in user display name in the SDK, You need to implement the following helper object in your code. The helper should have the following methods implemented.
This should return the display name of the logged-in user.
Sample Implementation:#
Incoming Call Listener#
When a user receives the incoming call, this callback event called.
Sample Response:#
Response Property Details:#
| Arguments | Description | 
|---|---|
| allUsers | JID's of the users in the call. | 
| callTime | Call intiated time in timestamp format. | 
| callType | Describe the audio or video call. | 
| groupId | Contain the group ID If the call is group call. Otherwise, the value will be NULL. | 
| localUser | To determine local user or not | 
| roomId | Call room ID. | 
| roomLink | Call room Link. | 
| status | Status of the call(calling, ringing, connecting, connected). | 
| toUsers | Array of User JID of callee users. | 
| userDetails | User details object of the callee users. | 
| userJid | User JID who intiated the call | 
| usersStatus | Array of users with the details of the call. | 
| from | One to one call User JID of callee users / One to many call User JID who intiated the call. | 
| to | One to one call User JID who intiated the call / One to many call Group JID. | 
| callMode | Mode of call. | 
Call Status Listener#
Handles Call Status, triggered whenever user call status changes.
Sample Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| status | user call status. | 
| userJid | From user JID | 
| localUser | User JID is current logged in user or another user. | 
| sessionStatus | Describe whether the call is closed or not. If the value is CLOSED means, no user in the call & call is disconnected completely. Otherwise call is in progress. | 
| usersStatus | Array of users with call details. | 
Possible Status:#
| Status | Description | 
|---|---|
| ringing | Callee user received the incoming call payload & Acknowledged it. | 
| connecting | User attended the received the call | 
| connected | Connection is established between the users | 
| reconnecting | There is a problem in connection between users | 
| engaged | When a user is in another call | 
| busy | When a user disconnect the in ringing state | 
| disconnected | User disconnect from the call | 
| ended | When another user ended the call | 
| hold | When user hold the call | 
User Track Listener#
In this listener, Receive the local & remote users audio & video tracks. We have localUser property to differentiate the remote & local users.
Sample Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| localUser | Identify whether the track is belongs to local or remote user true - Local user false - Remote user. | 
| track | Track object | 
| trackType | Contain audio or video to identify type of track. | 
| userJid | From user JID | 
| usersStatus | Array of users with call details. | 
Sample Javascript code to play the track#
You need to supply the track object which was received in the callback method to the audio/video element based on the track type that you have received.
note
You need to have multiple Audio and Video tag element to play all user's audio and video.
warning
For the Audio/Video call, you shouldn't play your own Audio track.
Mute Status Listener#
Whenever a user mute/unmute the video/audio, this event listener will be called with mute/unmute status details.
Sample Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| isMuted | Indetify whether the track is muter/unmuted. true - Muted false - Unmuted. | 
| trackType | Contain audio or video to identify type of track is muted/unmuted. | 
| userJid | From user JID. | 
Call Switch Listener#
When a user Request, Cancel, Accept & Decline a video call switch process, this event listener will be called with status information.
Sample Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| status | Status of the call switch process. | 
| userJid | From user JID. | 
| localUser | User JID is current logged in user or another user | 
| usersStatus | Array of users with the details of the call. | 
Possible Status:#
| Status | Description | 
|---|---|
| request | When a user initiate the call switch request, the current user will receive the request status | 
| cancel | When a user who initiate the call switch cancel the request, the current user will receive the cancel status | 
| accept | When a user accept the request, the call switch initiator will receive the accept status | 
| decline | When a user decline the request, the call switch initiator will receive the decline status | 
| timeout | No response from user | 
Invite Users Listener#
When a user who is already in the call invite the new users and the rest of the users who are already in call will receive the invited users details in this callback event listener.
The invited users will receive the incoming call in ["incomingCallListener"] callback listener.
Sample Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| allUsers | Array of User JID of caller & callee users. | 
| callTime | Call intiated time in timestamp format. | 
| callType | Describe the audio or video call. | 
| groupId | Contain the group ID If the call is group call. Otherwise, the value will be NULL. | 
| roomId | Call room ID. | 
| inviteUsers | Array of User JID who are invited. | 
| status | Status of the call. | 
| toUsers | Array of User JID who are all in the call currently. | 
| userJid | User JID who intiated the call | 
Missed Call Listener#
When a user already in call & the same user receives a call from the third user, this second call will be consider as a missed call & at this time this event will be called with second call details.
Sample Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| callTime | Call intiated time in timestamp format. | 
| callType | Describe the audio or video call. | 
| groupId | Contain the group ID If the call is group call. Otherwise, the value will be NULL. | 
| roomId | Call room ID. | 
| status | Status of the call(calling). | 
| toUsers | Array of User JID of callee users. | 
| userJid | User JID who intiated the call | 
Media Error Listener#
When user deny the audio/video browser permission or audio/video devices are not able to read by browser, at the time this event will be called with error details.
Sample Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| action | In which action error occurred(makeCall, answerCall, videoUnMute, callSwitch). | 
| device | Name of the device which has error (mic, camera, mic & camera) | 
| error | Describe the error type | 
| statusCode | Status Code | 
| message | Error meesage | 
Possible Error:#
| Error | Description | 
|---|---|
| NotAllowedError | Permission denied. | 
| NotFoundError | Requested device not found or readable. | 
Call Speaking Listener#
Handles the audio level, triggered whenever there is a change in the audio level of the current user or any other users on the call.
Sample Speaking Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| userJid | Speaking user JID | 
| isSpeaking | Whether the user is speaking or not | 
| localUser | Speaking user JID is current logged in user or another user. | 
| volumeLevel | Volume level is at which the user is speaking. Based on this level you can show the mic indicator for a particular user. Possible values will be between 0 to 10. When the value is 0, it’s referred to as the silent. When the value is 10, it’s referred to as the loudest. | 
Call Users Update Listener#
When there is an update in the users list of the call, callUsersUpdateListener() will be triggered with the list of the users on the call. You can update the UI based on this callback. When the list is empty, then the call is ended. So you can discard your UI.
Sample Call Users Update Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| userJid | User JID of current user | 
| localUser | User JID is current logged in user or another user | 
| usersList | List of users on the call | 
Call User Joined Listener#
Call user joined listener callUserJoinedListener() will be triggered when a new user joined into the call. You can use this method to show user joined toast in the UI.
Sample Call User Joined Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| userJid | User JID of the user who joined the call | 
| localUser | User JID is current logged in user or another user. | 
Call User Left Listener#
Call user left listener callUserLeftListener() will be triggered when a user left the call. You can use this method to show user left toast in the UI.
Sample Call User Left Response:#
Response Property Details:#
| Property | Description | 
|---|---|
| userJid | User JID of the user who left the call | 
| localUser | User JID is current logged in user or another user. |