Skip to main content

How can I listen for an audience joining or leaving an interactive live streaming channel?

The Agora Video 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 Signaling 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.

Implementation

  1. Enable the message notification service.
  2. 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:
event_typeevent_nameDescriptionField name of payload
105audience join channelIn the LIVE_BROADCASTING profile, an audience joins the channel.
  • channelName
  • uid
  • platform
  • ts
106audience leave channelIn the LIVE_BROADCASTING profile, an audience leaves the channel
  • channelName
  • uid
  • platform
  • reason
  • ts

Use the signaling service

The Agora Signaling SDK aims at providing stable signaling services, such as maintaining the channel information and sending real-time messages, for various social and education scenarios.

Implementation

By integrating both the Agora Video SDK and the Agora Signaling SDK, you can listen for the callback events of the Signaling SDK to detect the states of the audience in the Video SDK channel:

  • Let a user join both an Video SDK and an Signaling channel. Ensure that the Video SDK channel and the Signaling channel share the same channel name.
  • Bind the actions of joining both channels in your code logic.
  • As a result, the Signaling SDK reporting that a user has joined the Signaling channel means that the user has joined the Video SDK channel as well. The same applies to a user leaving the channel.

Reference

Refer to the following documents for detailed integration guide and API reference:

vundefined