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 make an end-to-end call. When receiving the invitation notification onReceiveNewInvitation, the invitee can choose to 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 onReceiveNewInvitation, an invitee can choose to accept the invitation, reject the invitation, or wait until the invitation times out.
Before an invitation times out and the invitee processes the invitation, the inviter can cancel the invitation via cancel. After the inviter cancels the invitation, an invitee will receive a cancellation notification onInvitationCancelled, and the invitation process ends.
When receiving an invitation onReceiveNewInvitation, an invitee can accept the invitation via accept before the invitation times out and the inviter cancels the invitation. If the invitee accepts the invitation, the inviter will receive an invitation acceptance notification onInviteeAccepted. After the processing (including 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 before the invitation times out and the inviter cancels the invitation. If the invitee rejects the invitation, the inviter will receive an invitation rejection notification onInviteeRejected. After the processing (including acceptance, rejection, and timeout) at the invitee side ends, the invitation process ends.
If the timeout duration of the invitation API is greater than 0 and an invitee does not respond within the timeout duration, the invitation times out, and the inviter and invitee will receive a timeout notification onInvitationTimeout. After the processing (including acceptance, rejection, and timeout) at the invitee side ends, the invitation process ends. If the timeout duration of the invitation API is 0, there will be no timeout notification.
In the open-source project TRTCFlutterScenesDemo, we developed an audio/video call solution suitable for one-to-one and multi-person chatting based on TRTC. You can directly modify the 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 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, including the call end event and call duration in the custom data 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 is hand raising 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.
Was this page helpful?