Adding Event Listeners
Use theaddEventListener() method to register event listeners. The method returns an unsubscribe function that you should call to remove the listener when no longer needed.
session.addEventListener(eventName, listener), with the same behavior. To ask whether there is a session right now, use CometChatCalls.getActiveSession():
getActiveSession() returns the session as soon as it starts preparing, before anyone joins: from the moment CometChatCalls.initiateCall has created the call on the caller, and from the moment CometChatCalls.connect is called on a ringing callee. It returns null again once the session ends, its prepare fails or is cancelled, or a prepared session expires after 5 minutes. While a session is only prepared, the SDK reports onConnected, onConnectionFailed (fatal errors only), onConnectionClosed and the roster events (onParticipantConnected, onParticipantJoined, onParticipantLeft, onParticipantListChanged); that is what lets a caller see “ringing” and “answered” without joining (see Ringing).
Session Events
Monitor the call session lifecycle including join/leave events and connection status.Connected
Fired when a prepared session has connected: signalling only, no camera or microphone, and other participants do not see you yet. It fires once per prepare (initiateCall on the caller, connect on the callee); the actual join is onSessionJoined.
Session Joined
Fired when you successfully connect to the session.Session Left
Fired when you leave the session.Session Timed Out
Fired when the session ends due to inactivity timeout. It is not used on a prepared session: one that nobody joins within 5 minutes reportsonConnectionClosed instead.
Connection Lost
Fired when the network connection is interrupted.Connection Restored
Fired when the connection is restored after being lost.Connection Closed
Fired when the connection is permanently closed. On a session that was only prepared (an outgoing call still ringing, or an incoming call this tab prepared), it means the call ended before anyone joined: declined, cancelled (in a 1:1 call), the room went away,leave() or endCall tore it down, or nobody joined within 5 minutes. The event carries no reason.
Participant Events
Monitor participant activities including join/leave, audio/video state, hand raise, screen sharing, and recording.Participant Connected
Fired when a remote participant’s device has prepared the session without joining it. On the caller’s prepared session, this is the callee’s device ringing.Participant Joined
Fired when a participant joins the call. On the caller’s prepared session, this is the callee answering: join withsession.join(container) now.