## Constructor

#### new Client(opts)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `opts` | Object | ###### Properties
  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `userId` | String |  | 玩家唯一 Id
  `appId` | String |  | APP ID
  `appKey` | String |  | APP KEY
  `ssl` | Boolean | <optional> | 是否使用 ssl，仅在 Client Engine 中可用
  `gameVersion` | String | <optional> | 游戏版本号

### Members

#### readonly lobbyRoomList

  获取房间列表

#### readonly player

  获取当前玩家

#### readonly room

  获取当前所在房间

### Methods

#### async close() [async]

  关闭

#### async connect() [async]

  建立连接

#### async createRoom(optsopt) [async]

  创建房间

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `opts` | Object | <optional> | 创建房间选项 ###### Properties
  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `roomName` | string | <optional> | 房间名称，在整个游戏中唯一，默认值为 null，则由服务端分配一个唯一 Id
  `roomOptions` | Object | <optional> | 创建房间选项，默认值为 null ###### Properties
  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `opened` | Boolean | <optional> | 房间是否打开
  `visible` | Boolean | <optional> | 房间是否可见，只有「可见」的房间会出现在房间列表里
  `emptyRoomTtl` | Number | <optional> | 房间为空后，延迟销毁的时间
  `playerTtl` | Number | <optional> | 玩家掉线后，延迟销毁的时间
  `maxPlayerCount` | Number | <optional> | 最大玩家数量
  `customRoomProperties` | Object | <optional> | 自定义房间属性
  `customRoomPropertyKeysForLobby` | Array.<string> | <optional> | 在大厅中可获得的房间属性「键」数组
  `flag` | CreateRoomFlag | <optional> | 创建房间标记，可多选
  `expectedUserIds` | Array.<string> | <optional> | 邀请好友 ID 数组，默认值为 null

#### async joinLobby() [async]

  加入大厅

#### async joinOrCreateRoom(roomName, optsopt) [async]

  随机加入或创建房间

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `roomName` | string |  | 房间名称
  `opts` | Object | <optional> | 创建房间选项 ###### Properties
  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `roomOptions` | Object | <optional> | 创建房间选项，默认值为 null ###### Properties
  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `opened` | Boolean | <optional> | 房间是否打开
  `visible` | Boolean | <optional> | 房间是否可见，只有「可见」的房间会出现在房间列表里
  `emptyRoomTtl` | Number | <optional> | 房间为空后，延迟销毁的时间
  `playerTtl` | Number | <optional> | 玩家掉线后，延迟销毁的时间
  `maxPlayerCount` | Number | <optional> | 最大玩家数量
  `customRoomProperties` | Object | <optional> | 自定义房间属性
  `customRoomPropertyKeysForLobby` | Array.<string> | <optional> | 在大厅中可获得的房间属性「键」数组
  `flag` | CreateRoomFlag | <optional> | 创建房间标记，可多选
  `expectedUserIds` | Array.<string> | <optional> | 邀请好友 ID 数组，默认值为 null

#### async joinRandomRoom(optsopt) [async]

  随机加入房间

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `opts` | Object | <optional> | 随机加入房间选项 ###### Properties
  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `matchProperties` | Object | <optional> | 匹配属性，默认值为 null
  `expectedUserIds` | Array.<string> | <optional> | 邀请好友 ID 数组，默认值为 null

#### async joinRoom(roomName, expectedUserIdsopt) [async]

  加入房间

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `roomName` | string |  | 房间名称
  `expectedUserIds` | * | <optional> | 邀请好友 ID 数组，默认值为 null

#### async kickPlayer(actorId, optsopt) [async]

  踢人

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `actorId` | Number |  | 踢用户的 actorId
  `opts` | Object | <optional> | 附带参数 ###### Properties
  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `code` | Number | <optional> | 编码
  `msg` | String | <optional> | 附带信息

#### async leaveLobby() [async]

  离开大厅

#### async leaveRoom() [async]

  离开房间

#### pauseMessageQueue()

  暂停消息队列处理

#### async reconnect() [async]

  重新连接

#### async reconnectAndRejoin() [async]

  重新连接并自动加入房间

#### async rejoinRoom(roomName) [async]

  重新加入房间

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `roomName` | string | 房间名称

#### resumeMessageQueue()

  恢复消息队列处理

#### async sendEvent(eventId, eventData, options) [async]

  发送自定义消息

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `eventId` | number | string | 事件 ID
  `eventData` | Object | 事件参数
  `options` | Object | 发送事件选项 ###### Properties
  Name | Type | Description
  --- | --- | ---
  `receiverGroup` | ReceiverGroup | 接收组
  `targetActorIds` | Array.<number> | 接收者 Id。如果设置，将会覆盖 receiverGroup

#### async setMaster(newMasterId) [async]

  设置房主

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `newMasterId` | number | 新房主 ID

#### async setRoomOpened(opened) [async]

  设置房间开启 / 关闭

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `opened` | Boolean | 是否开启

#### async setRoomVisible(visible) [async]

  设置房间可见 / 不可见

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `visible` | Boolean | 是否可见