Join Chatroom
By default, a single user cannot join multiple chatrooms simultaneously. Joining a new chatroom will automatically exit the previous one.
To enable a single user to join multiple chatrooms, you can enable this configuration in the Console. For details, refer to Chatroom Service Configuration.
Join Chatroom
Method
joinChatRoom(
targetId: string,
messageCount: number,
autoCreate: boolean,
callback: IRCIMIWJoinChatRoomCallback
): Promise<number>;
Parameter Description
Parameter | Type | Description |
---|---|---|
targetId | string | The chatroom conversation ID |
messageCount | number | The number of messages to pull when entering the chatroom. -1 means no messages will be pulled, 0 means 10 messages will be pulled, and the maximum is 50 |
autoCreate | boolean | Whether to create the chatroom. If TRUE, the SDK will create the chatroom and join it if it doesn’t exist. If it already exists, the SDK will join directly |
callback | IRCIMIWJoinChatRoomCallback | Callback for the result of the API call |
Return Value
Return Value | Description |
---|---|
number | The status code of the current API operation. 0 indicates a successful call. The specific result needs to be handled in the callback. Non-zero values indicate that the current API call failed, and the callback will not be triggered. For detailed error codes, refer to the error code documentation |
Code Example
const callback = {
onChatRoomJoined: (code: number, targetId: string) => {
//...
},
};
let code = await engine.joinChatRoom(targetId, messageCount, autoCreate, callback);
- The SDK provides a chatroom reconnection mechanism. When the connection is restored, if the user had previously joined a chatroom and did not exit, the SDK will rejoin the chatroom.