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.

function getDisplayName() {}

This should return the display name of the logged-in user.

Sample Implementation:#

let callbackObject = {
...,
helper: {
getDisplayName: () => return displayName
}
}

Incoming Call Listener#

When a user receives the incoming call, this callback event called.

function incomingCallListener(response) {}

Sample Response:#

// Response Structure
{
allUsers:["USER1_JID", "USER2_JID"],
callMode: "onetoone",
callTime: 1681905421215,
callType: "audio|video",
from: "USER_JID|FROM_USER_JID",
groupId: null|GROUP_ID,
localUser: BOOLEAN,
roomId: "wmupbheao",
roomLink: "ndy-bmkb-eui"
status: "calling",
to: "FROM_USER_JID|GROUP_JID",
toUsers: ["USER_JID"],
userDetails: {},
userJid: "FROM_USER_JID",
usersStatus: [{}]
}

Response Property Details:#

ArgumentsDescription
allUsersJID's of the users in the call.
callTimeCall intiated time in timestamp format.
callTypeDescribe the audio or video call.
groupIdContain the group ID If the call is group call. Otherwise, the value will be NULL.
localUserTo determine local user or not
roomIdCall room ID.
roomLinkCall room Link.
statusStatus of the call(calling, ringing, connecting, connected).
toUsersArray of User JID of callee users.
userDetailsUser details object of the callee users.
userJidUser JID who intiated the call
usersStatusArray of users with the details of the call.
fromOne to one call User JID of callee users / One to many call User JID who intiated the call.
toOne to one call User JID who intiated the call / One to many call Group JID.
callModeMode of call.

Call Status Listener#

Handles Call Status, triggered whenever user call status changes.

function callStatusListener(response) {}

Sample Response:#

// Response Structure
{
localUser: 'BOOLEAN',
sessionStatus: null|'closed',
status: "ringing|connecting|connected|busy|engaged|ended|reconnecting|disconnected|hold",
userJid: "FROM_USER_JID",
usersStatus: "USERS_ARRAY_OF_OBJECT"
}

Response Property Details:#

PropertyDescription
statususer call status.
userJidFrom user JID
localUserUser JID is current logged in user or another user.
sessionStatusDescribe 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.
usersStatusArray of users with call details.

Possible Status:#

StatusDescription
ringingCallee user received the incoming call payload & Acknowledged it.
connectingUser attended the received call
connectedConnection is established between the users
reconnectingThere is a problem in connection between users
engagedWhen a user is in another call
busyWhen a user disconnect the call in ringing state
disconnectedUser disconnected from the call
endedWhen another user ended the ongoing call

User Track Listener#

In this listener, receive the local & remote users audio tracks. We have localUser property to differentiate the remote & local users.

function userTrackListener(response) {}

Sample Response:#

// Response Structure
{
localUser: 'BOOLEAN',
track: 'TRACK_OBJECT',
trackType: "audio|video",
userJid: "FROM_USER_JID",
usersStatus: "USERS_ARRAY_OF_OBJECT"
}

Response Property Details:#

PropertyDescription
localUserIdentify whether the track is belongs to local or remote user
true - Local user
false - Remote user.
trackTrack object
trackTypeContain audio or video to identify type of track.
userJidFrom user JID
usersStatusArray of users with call details.

Mute Status Listener#

Whenever a user mute/unmute the video/audio, this event listener will be called with mute/unmute status details.

function muteStatusListener(response) {}

Sample Response:#

// Response Structure
{
isMuted: 'BOOLEAN',
trackType: "audio|video",
userJid: "FROM_USER_JID"
}

Response Property Details:#

PropertyDescription
isMutedIndetify whether the track is muted/unmuted.
true - Muted
false - Unmuted.
trackTypeContain audio or video to identify type of track is muted/unmuted.
userJidFrom user JID.

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.

function missedCallListener(response) {}

Sample Response:#

// Response Structure
{
callTime: 1681905421215,
callType: "audio|video",
groupId: null|`GROUP_ID`,
roomId: "wmupbheao",
status: "calling",
toUsers: ["USER_JID"]
userJid: "FROM_USER_JID"
}

Response Property Details:#

PropertyDescription
callTimeCall intiated time in timestamp format.
callTypeDescribe the audio or video call.
groupIdContain the group ID If the call is group call. Otherwise, the value will be NULL.
roomIdCall room ID.
statusStatus of the call(calling).
toUsersArray of User JID of callee users.
userJidUser JID who intiated the call

Media Error Listener#

When user deny the microphone permission or audio devices are not able to read by app, at the time this event will be called with error details.

function mediaErrorListener(response) {}

Sample Response:#

// Response Structure
{
action: "makeCall",
device: "mic",
error: "Microphone permission denied",
statusCode: "STATUS_CODE"
message: "Microphone permission denied",
userJid: "FROM_USER_JID"
}

Response Property Details:#

PropertyDescription
actionIn which action error occurred(makeCall, answerCall).
deviceName of the device which has error (mic, camera, mic & camera)
errorDescribe the error type
statusCodeStatus Code
messageError meesage

Possible Error:#

ErrorDescription
Microphone permission deniedMicrophone Permission denied.

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.

function callSpeakingListener(response) {}

Sample Speaking Response:#

// Response Structure
{
isSpeaking: "true|false"
localUser: "true|false"
userJid: "FROM_USER_JID"
volumeLevel: 3
}

Response Property Details:#

PropertyDescription
userJidSpeaking user JID
isSpeakingWhether the user is speaking or not
localUserSpeaking user JID is current logged in user or another user.
volumeLevelVolume 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.