Nafaa Azaiez
Nafaa Azaiez

Reputation: 131

Agora.io : Use timeout or api to close unused channels

I am using agora.io to implement 1-to-1 video call in android and I want to know:

I need this to be sure if users leave the channel or if one leave and the other keep the channel open without really using it, i need to close the unused channels...

Upvotes: 5

Views: 2075

Answers (2)

Hermes
Hermes

Reputation: 2898

Within Agora channels are ephemeral, when a client app uses the joinChannel method it creates a request to join a channel if it doesn't exist, Agora's platform will create the channel and add the user into it. When a second client uses the joinChannel method with the same channel name, the platform will connect them into the same channel. When all the user's leave a channel it remains open for a few seconds, and then Agora's platform automatically closes/destroys the channel.

There are a few different approaches to achieve the feature you describe where calls only last for a certain period of time and for how to keep users from lingering in calls.

I'll start with timed calls. Within your app/client, you can create a timer that after XX minutes calls the Agora SDK's leaveChannel method so forcing channels to have a certain life time.

If you don't want this have this on the client, you can create a server that keeps track of when two people join a channel, and use the Kicking Rule within the Agora RESTful API. Your server would implement the timer, and then use the kicking rule to clear the channel. When using kicking rules, you don't have to specify the user, you can specify only a channel and that will remove all users from the channel.

Note: When using kick rules that only specify a channel, be cautious of the amount of time you set because this blocks all users from joining that channel.

To address the lingering users, one approach is to use the userJoined callback to count the users in the call, and the userLeft callback to check if all other users have left the channel. If a user is the last one in the channel you can call leaveChannel on the client.

Another approach is to use Agora RTM as a more robust signaling layer. You can use data channels to synchronize when two users should join a channel or use RTM's userLeft callback and getChannelMemberCount to count the total clients within a channel and have finer control over how users connect.

Upvotes: 2

ogelacinyc
ogelacinyc

Reputation: 1372

There are no feature for scheduled closing channel.

But Agora has a feature to handle callblack event after someone left channel.

Agora send broadcast message when user left the channel after a few seconds.

Other user receive the message which someone lefted channel by callback message, then it can be force closing channel by using event handler('on').

See this documentation.

https://docs.agora.io/en/Voice/API%20Reference/web_ng/interfaces/iagorartcclient.html#on

Upvotes: 0

Related Questions