Signaling APIs are a set of invitation process control APIs based on IM messages. They can be used to implement a variety of real-time features, including:
Signaling APIs support the following features:
When making a one-to-one chat via the simple message sending or receiving API or rich media message sending or receiving API, you can use the invite signaling API to initiate an end-to-end call invitation. When receiving the invitation notification onReceiveNewInvitation, the invitee can accept the invitation, reject the invitation, or wait until the invitation times out.
First, you need to manage a group by using group management APIs and listen for the group's event callbacks via V2TIMGroupListener. Then members of the group can initiate a group call invitation via inviteInGroup within the group. When receiving the invitation notification onReceiveNewInvitation, an invitee can accept the invitation, reject the invitation, or wait until the invitation times out.
If an invitation has not timed out and has not been processed by an invitee, the inviter can cancel the invitation via cancel. After the inviter cancels the invitation, the invitee receives a cancellation notification onInvitationCancelled, and the invitation process ends.
When receiving an invitation notification onReceiveNewInvitation, an invitee can accept the invitation via accept if the invitation has not timed out and has not been canceled by the inviter. If the invitee accepts the invitation, the inviter receives an invitation acceptance notification onInviteeAccepted. After the processing (including invitation acceptance, rejection, and timeout) at the invitee side ends, the invitation process ends.
When receiving an invitation notification onReceiveNewInvitation, an invitee can reject the invitation via reject if the invitation has not timed out and has not been canceled by the inviter. If the invitee rejects the invitation, the inviter receives an invitation rejection notification onInviteeRejected. After the processing (including invitation acceptance, rejection, and timeout) at the invitee side ends, the invitation process ends.
If the timeout period of the invitation API is greater than 0 and the invitee does not respond within the timeout period, the invitation times out, and the inviter and invitee will receive a timeout notification onInvitationTimeout. After the processing (including invitation acceptance, rejection, and timeout) at the invitee side ends, the invitation process ends. If the timeout period of the invitation API is 0, there will be no timeout notification.
In the open-source project TUIKit Demo, we developed a one-to-one and group audio/video call solution based on the TRTC component TUICalling for chat scenarios. You can directly modify the TUIKit demo for adaptation. The following takes the one-to-one video call process as an example to introduce how signaling APIs work with the TRTC SDK.
One-to-one video call process:
openCamera()
function to enable the local camera. The inviter and invitee receive the onRemoteUserEnterRoom
callback from the TRTC SDK, and the systems of the two parties record the start time of the call.onUserVideoAvailable
event notification from the TRTC SDK, which indicates that they have received each other's video image. At this point, they can call the startRemoteView
API of the TRTC SDK to display the remote video image, and the remote audio will be automatically played back by default.onRemoteUserLeaveRoom
callback from the TRTC SDK, and its system calculates the total duration of the call and initiates an invitation again. The custom data in the invitation specifies the call end event and call duration to facilitate UI display.Flowchart
In this scenario, the teacher asks students to raise hands and then chooses one of the students to speak. The process is as follows:
data
. The students receive the onReceiveNewInvitation callback.inviteeList
and data
fields in onReceiveNewInvitation, a student determines that he/she is one of the invitees and the operation is hand raising. Then the student calls the accept API to raise her/his hand.data
field specifies the hand raising operation and displays the list of students who raise hands.data
. The students receive the onReceiveNewInvitation callback.inviteeList
and data
fields in the onReceiveNewInvitation callback, a student determines that he/she is one of the invitees and the operation is speaking. Then the student calls the accept API to speak.data
field specifies the speaking operation and display the list of students who speak.The signaling APIs (iOS | Android) provided by the IM SDK does not limit the invitation logic. One user can receive multiple signaling invitations at the same time. For the audio/video call scenario, the component TUICalling provides a "busy" alert.
Yes. The upper-layer semantics need to distinguish the required operations in the invitations based on the actual business requirements.
You can call the invite API of the IM SDK to initiate an invitation and specify the current invitation as a connection or hang-up request in the custom data of the API. Then, IM passes through the invitation to the peer for processing.
onInvitationTimeout
callback.onInvitationTimeout
callback.If you cold start the app (kill the process and click the app icon again to start the app), there are two situations depending on the chat type:
onReceiveNewInvitation
.onReceiveNewInvitation
.onReceiveNewInvitation
, no matter whether the current chat is a one-to-one or group chat.inviteID
unique in signaling callbacks?Yes. An inviteID
is a unique identifier of a set of signaling messages (including invitation initiation, acceptance/rejection, and timeout messages).
Was this page helpful?