In a live interactive streaming channel, the host can invite an audience to take on the role of co-host, or change role back to audience.
You can implement this function by combining the following features:
- Signaling and channel attributes using methods from the Agora Signaling SDK.
- Setting the user role using methods from the Agora Video SDK.
Before proceeding, ensure that you have integrated both the Agora Signaling SDK and Video SDK in your project. For how to integrate these SDKs, see the following guides:
The basic API call sequence is as follows:
Refer to the detailed steps for implementation:
- The host calls v to send a peer-to-peer message that invites an audience to take on the role pf co-host.
- The audience receives the invitation message in the
- The audience calls
setClientRoleto change the user role to
- After successfully changing the user role, the audience receives the
onClientRoleChangedcallback, and becomes a co-host.
- The new co-host calls
onMessageReceivedto notify the role change to all users in the channel.
- The host receives the
onAttributesUpdated) callback, and starts co-hosting with the new co-host.
To change a co-host back to an audience, follow the same steps, except when calling
setClientRole, set the user role as
The methods mentioned in this article are in Java. Refer to the following table if you are programming in a different language: