Leaving an open channel
Users can leave an open channel in two ways:
- Automatic removal: The open channel has an offline participant auto-kick mechanism. When triggered, the server removes the user. Banned users are also kicked automatically.
- Voluntary leave: The client SDK provides an API for users to leave voluntarily.
Automatic removal
Offline participants are automatically removed under the following default conditions:
- Within 30 seconds of going offline, if the channel receives its 31st message, the user is kicked.
- After 30 seconds offline, the user is kicked when any new message arrives.
tip
- Both conditions require new messages in the channel. If no messages are sent, offline users are not kicked.
- To remove dependency on new messages, request Real-time Abnormal Disconnect Kick via a support ticket. This lets the server detect abnormal states and kick users within 5 minutes.
- To protect specific users from being kicked (for example, hosts in a live stream), use the Server API Participant Allowlist.
Voluntary leave
Use openChannel.exitChannel() to voluntarily leave an open channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
extra | String | Additional information to send when leaving the channel. Default is "". Max 128 characters. |
handler | ErrorHandler? | Callback. error is null on success. |
- Kotlin
- Java
kotlin
val openChannel = OpenChannel("openChannelId")
openChannel.exitChannel(extra = "user left voluntarily") { error ->
if (error == null) {
// Left successfully
} else {
// Leave failed
}
}
Java
OpenChannel openChannel = new OpenChannel("openChannelId");
openChannel.exitChannel("user left voluntarily", error -> {
if (error == null) {
// Left successfully
} else {
// Leave failed
}
});