joinChatRoom method

Future<void> joinChatRoom(
  1. String roomId, {
  2. bool leaveOtherRooms = false,
  3. String? ext,
})

Joins the chat room.

To exit the chat room, call leaveChatRoom.

Param roomId The ID of the chat room to join.

Param leaveOtherRooms Whether to leave all the currently joined chat rooms when joining a chat room.

Param ext The extension information.

Throws A description of the exception. See ChatError.

Implementation

Future<void> joinChatRoom(
  String roomId, {
  bool leaveOtherRooms = false,
  String? ext,
}) async {
  try {
    Map req = {
      "roomId": roomId,
      "leaveOtherRooms": leaveOtherRooms,
    };
    req.putIfNotNull("ext", ext);

    Map result = await platform_interface.Client.instance.chatRoomManager
        .callNativeMethod(ChatMethodKeys.joinChatRoom, req);
    ChatError.hasErrorFromResult(result);
  } catch (e) {
    rethrow;
  }
}