Skip to main content
Version: 2.x.x

Meeting Class Callbacks - Unity


OnCreateMeetingIdCallbackโ€‹

The OnCreateMeetingIdCallback is triggered when a new meeting ID is successfully created using the CreateMeetingId() method.

Parametersโ€‹

  • meetingId: string
    • The newly created meeting ID.

Usageโ€‹

Register this callback to receive the generated meeting ID upon successful execution of CreateMeetingId().

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnCreateMeetingIdCallback += (meetingId) =>
{
Debug.Log("Meeting ID created: " + meetingId);
};
meeting.CreateMeetingId("YOUR_TOKEN");

OnCreateMeetingIdFailedCallbackโ€‹

The OnCreateMeetingIdFailedCallback is triggered when the attempt to create a meeting ID using the CreateMeetingId() method fails.

Parametersโ€‹

  • error: string
    • The error message describing why the meeting ID creation failed.

Usageโ€‹

Register this callback to handle errors that may occur during meeting ID creation.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnCreateMeetingIdFailedCallback += (error) =>
{
Debug.LogError("Failed to create meeting ID: " + error);
};
meeting.CreateMeetingId("YOUR_TOKEN_HERE");

OnParticipantJoinedCallbackโ€‹

The OnParticipantJoinedCallback is triggered for all participants (local or remote) when a participant joins the meeting. It provides the IParticipant object representing the participant who joined.

Parametersโ€‹

  • participant: IParticipant
    • The participant who joined the meeting.

Usageโ€‹

Register this callback to receive information when any participant joins the meeting.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnParticipantJoinedCallback += (iParticipant) =>
{
Debug.Log("Participant joined: " + iParticipant.Name);
};

OnParticipantLeftCallbackโ€‹

The OnParticipantLeftCallback is triggered for all participants (local or remote) when a participant leaves the meeting. It provides the IParticipant object representing the participant who left.

Parametersโ€‹

  • participant: IParticipant
    • The participant who left the meeting.

Usageโ€‹

Register this callback to receive information when any participant leaves the meeting.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnParticipantLeftCallback += (iParticipant) =>
{
Debug.Log("Participant left: " + iParticipant.Name);
};

OnMeetingStateChangedCallbackโ€‹

The OnMeetingStateChangedCallback is triggered whenever there is a change in the meeting state. This can include transitions such as connecting, connected, reconnecting, or disconnected.

Parametersโ€‹

  • state: MeetingState
    • The updated meeting state. Possible values include:

      • MeetingState.NONE
        The initial state before any meeting-related operation has started.

      • MeetingState.CONNECTING
        Indicates that the participant is in the process of joining the meeting.

      • MeetingState.CONNECTED
        Indicates that the participant has successfully joined the meeting.

      • MeetingState.RECONNECTING
        Indicates that the connection was interrupted and a reconnection attempt is in progress.

      • MeetingState.DISCONNECTED
        Indicates that the participant has left the meeting or the connection has been terminated.

Usageโ€‹

Register this callback to monitor and respond to changes in the meeting's connection state.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnMeetingStateChangedCallback += (state) =>
{
Debug.Log("Meeting state changed: " + state);
};

OnErrorCallbackโ€‹

The OnErrorCallback is triggered when an error occurs during meeting operations, such as joining, leaving, or interacting with media devices. It provides an Error object containing details about the issue.

Parametersโ€‹

  • error: Error
    • An object representing the error. The Error class includes the following properties:

      • code: string

        • A short code identifying the type of error.
      • message: string

        • A descriptive message explaining the error.
      • type: string

        • The type of error.

Usageโ€‹

Register this callback to handle and respond to runtime errors that occur while interacting with the meeting.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnErrorCallback += (error) =>
{
Debug.LogError("Error occurred:");
Debug.LogError("Code: " + error.code);
Debug.LogError("Message: " + error.message);
Debug.LogError("Type: " + error.type);
};

OnSpeakerChangedCallbackโ€‹

The OnSpeakerChangedCallback is triggered when the active speaker changes in the meeting. It provides the participant ID of the new active speaker.

Parametersโ€‹

  • participantId: string
    • The unique identifier of the participant who is currently the active speaker.

Usageโ€‹

Use this callback to track and highlight the participant who is currently speaking.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnSpeakerChangedCallback += (participantId) =>
{
Debug.Log("Active speaker changed. Participant ID: " + participantId);
};

OnPausedAllStreamsCallbackโ€‹

The OnPausedAllStreamsCallback is triggered when all remote participants' media streams of a specific type (audio or video) have been successfully paused.

Parametersโ€‹

  • streamKind: StreamKind
    • Indicates the type of stream that was paused. Possible values:
      • StreamKind.AUDIO
      • StreamKind.VIDEO

Usageโ€‹

Use this callback to confirm that all audio or video streams have been paused.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnPausedAllStreamsCallback += (streamKind) =>
{
Debug.Log("All " + streamKind + " streams have been paused.");
};

OnResumedAllStreamsCallbackโ€‹

The OnResumedAllStreamsCallback is triggered when all remote participants' media streams of a specific type (audio or video) have been successfully resumed.

Parametersโ€‹

  • streamKind: StreamKind
    • Indicates the type of stream that was resumed. Possible values:
      • StreamKind.AUDIO
      • StreamKind.VIDEO

Usageโ€‹

Use this callback to confirm that all audio or video streams have been resumed.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnResumedAllStreamsCallback += (streamKind) =>
{
Debug.Log("All " + streamKind + " streams have been resumed.");
};

OnCallStartedCallbackโ€‹

The OnCallStartedCallback is triggered when an external call starts, whether itโ€™s a traditional phone call or a VoIP call (e.g., WhatsApp).

Parametersโ€‹

  • None

Usageโ€‹

Use this callback to manage interruptions caused by external calls. To ensure the local participant does not hear remote participants or speak in the meeting during the external call:

  • Disable the microphone for the local participant using SetAudio(false).
  • Pause incoming audio streams from remote participants using PauseAllStreams(StreamKind.AUDIO).

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnCallStartedCallback += () =>
{
Debug.Log("External call started.");
// Disable local participant's audio
localParticipant.SetAudio(false);

// Pause remote streams
meeting.PauseAllStreams(StreamKind.AUDIO);
};

OnCallHangupCallbackโ€‹

The OnCallHangupCallback is triggered when an external call ends, whether itโ€™s a traditional phone call or a VoIP call (e.g., WhatsApp).

Parametersโ€‹

  • None

Usageโ€‹

Use this callback to handle any updates or resume actions when an external call interruption ends. If you previously disabled the local participant's microphone and paused remote participants' audio streams in the OnCallStartedCallback, make sure to re-enable them here:

  • Use SetAudio(true) to allow the local participant to speak again.
  • Use ResumeAllStreams(StreamKind.AUDIO) to allow the local participant to hear remote participants again.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnCallHangupCallback += () =>
{
Debug.Log("External call ended.");

// Re-enable local microphone
localParticipant.SetAudio(true);

// Resume audio streams of remote participants
meeting.ResumeAllStreams(StreamKind.AUDIO);
};

OnCallRingingCallbackโ€‹

The OnCallRingingCallback is triggered when an incoming external call is ringing, before it is answered. This includes both traditional phone calls and VoIP calls (e.g., WhatsApp).

Parametersโ€‹

  • None

Usageโ€‹

Use this callback to prepare the application for an incoming call. For example, you may want to display a UI indicator.

Exampleโ€‹

Meeting meeting = Meeting.GetMeetingObject();
meeting.OnCallRingingCallback += () =>
{
Debug.Log("External call is ringing.");
// Optional: Notify user
}

Got a Question? Ask us on discord