Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Home
/
Chat
/
JavaScript
/
Channel
This is the new Docs for Chat SDK v4 for JavaScript. To see the previous Docs, click here.

Enter and exit an open channel

A user can receive messages from the open channels they enter. They can enter up to ten channels and receive messages as long as they are connected to the Sendbird server. If the user is disconnected from the server, they will 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-enter the open channels.

If the client app is in the background, the user will be disconnected from the Sendbird server. However, when the client app runs in the foreground again, the Chat SDK will automatically reconnect the open channels the user has entered. When a user temporarily loses connection to the Sendbird server due to unstable connection, the SendbirdChat instance will attempt 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. When a user exits, they can't receive messages from the channel anymore.

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