Leave an open channel
Remove the current user from an open channel. After leaving, the user stops receiving messages from the channel.
Leave an open channel
TypeScript
import { OpenChannel } from '@nexconn/chat';
const channel = new OpenChannel('<open-channel-id>');
const { code } = await channel.exitChannel('source=leave-button');
if (code === 0) {
console.log('Left the open channel');
} else {
console.log('Failed to leave. Code:', code);
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
extra | string | No | Optional extra data to send when exiting the open channel. |
Return value
| Field | Type | Description |
|---|---|---|
isOk | boolean | Whether the exit request succeeded. |
code | number | Status code. 0 means success. |
info
- Leaving an open channel immediately stops message delivery for the user.
- The user can rejoin the same open channel later using
enterChannel. - Calling
disconnectalso exits the user from joined open channels automatically.