Skip to main content

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

ParameterTypeRequiredDescription
extrastringNoOptional extra data to send when exiting the open channel.

Return value

FieldTypeDescription
isOkbooleanWhether the exit request succeeded.
codenumberStatus 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 disconnect also exits the user from joined open channels automatically.