The Agora RTC SDK does not provide any callback events that listen for an audience joining or leaving an interactive live streaming channel. However, you can listen for these events using either of the following two approaches:
- By using the event notifications provided by Agora's message notification service.
- By using the signaling service provided by the Agora RTM SDK.
Use the message notification service (Beta)
Agora Message Notification Service is in the Beta stage. Agora recommends that core apps should not rely on the Message Notification Service.
The message notification service enables you to listen for various service events, which are sent to your Server in the form of HTTP/HTTPS requests.
- Follow the steps in User configuration to enable the message notification service.
- Once the service is enabled, the message notification service sends messages to your Server as HTTP/HTTPS POST requests. Listen for the following events of the Real-Time Communication service to detect whether an audience joins or leaves an interactive live streaming channel:
||Field name of payload
audience join channel
LIVE_BROADCASTING profile, an audience joins the channel.
audience leave channel
LIVE_BROADCASTING profile, an audience leaves the channel
Refer to the following documents for more detailed steps and descriptions:
Use the signaling service
The Agora RTM SDK aims at providing stable signaling services, such as maintaining the channel information and sending real-time messages, for various social and education scenarios.
By integrating both the Agora RTC SDK and the Agora RTM SDK, you can listen for the callback events of the RTM SDK to detect the states of the audience in the RTC channel:
- Let a user join both an RTC and an RTM channel. Ensure that the RTC channel and the RTM channel share the same channel name.
- Bind the actions of joining both channels in your code logic.
- As a result, the RTM SDK reporting that a user has joined the RTM channel means that the user has joined the RTC channel as well. The same applies to a user leaving the channel.
Refer to the following documents for detailed integration guide and API reference: