Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Version 4
Home
/
Chat
/
JavaScript
/
Channel

Enter and exit an open channel

Copy link

A user can enter up to ten open channels and only receives messages from the entered channels. If the user is disconnected from the Sendbird server, they no longer receive messages. To continue receiving messages from the participating open channels, the user has to be reconnected to the server by calling connect() and re-entering the open channels.

If the client app is in the background, the user is disconnected from the Sendbird server. However, when the client app runs in the foreground again, the Chat SDK automatically reconnects the open channels the user has entered. When a user temporarily loses connection to the Sendbird server due to an unstable connection, the SendbirdChat instance attempts to reconnect the user and also reconnects the open channels the user has entered.

const channel: OpenChannel = sb.openChannel.getChannel(CHANNEL_URL);
await channel.enter();

A user can exit open channels as shown below. After exiting, the user an no longer receive messages from the channel.

const channel: OpenChannel = sb.openChannel.getChannel(CHANNEL_URL);
await channel.exit();