Skip to main content

Join an open channel

A user must join an open channel before sending or receiving messages. Joining an open channel connects the user to the channel and optionally fetches recent message history.

Join an open channel

TypeScript
import { OpenChannel } from '@nexconn/chat';

const channel = new OpenChannel('<open-channel-id>');
const result = await channel.enterChannel({
messageCount: 10,
extra: 'source=campaign',
});
if (result.isOk) {
console.log('Joined open channel:', result.data.memberCount);
console.log('Joined at:', result.data.enterTime);
} else {
console.log('Join failed. Code:', result.code);
}

Parameters

ParameterTypeRequiredDescription
messageCountnumberYesNumber of recent messages to fetch when joining.
extrastringNoOptional business context data to send with the enter request.

Return value

enterChannel() returns Promise<NCResult<OpenChannelEnterResponseInfo>>.

FieldTypeDescription
isOkbooleanWhether the enter request succeeded.
codenumberStatus code. 0 means success.
dataOpenChannelEnterResponseInfo | undefinedOpen channel info returned after a successful join.

OpenChannelEnterResponseInfo

FieldTypeDescription
createTimenumberChannel creation timestamp in milliseconds
memberCountnumberCurrent number of members in the channel
isAllChannelMutedbooleanWhether the entire channel is muted
isCurrentUserMutedbooleanWhether the current user is muted globally
isCurrentChannelMutedbooleanWhether the current user is muted in this channel
isCurrentChannelInAllowlistbooleanWhether the current user is in this channel's mute allowlist
enterTimenumberTimestamp when the current user joined the channel
info
  • If the connection is interrupted unexpectedly and then restored, the SDK automatically attempts to rejoin previously joined open channels.
  • If the user disconnects intentionally, the SDK exits open channels automatically.
  • By default, a user can join only one open channel at a time.