## 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> | 游戏版本号
  `playServer` | String | <optional> | 路由地址

### Members

#### readonly lobbyRoomList :Array.<LobbyRoom>

  获取房间列表

#### readonly player :Player

  获取当前玩家

#### readonly room :Room

  获取当前所在房间

#### readonly userId :String

  获取用户 id

### Methods

#### async addRoomExpectedUserIds(expectedUserIds) [async]

  增加房间占位玩家 Id 列表

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `expectedUserIds` | * | 增加的玩家 Id 列表

#### async clearRoomExpectedUserIds() [async]

  清空房间占位玩家 Id 列表

#### 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
  --- | --- | --- | ---
  `open` | 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
  --- | --- | --- | ---
  `open` | 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

#### 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]

  离开房间

#### async matchRandom(optsopt) [async]

  随机匹配，匹配成功后并不加入房间，而是返回房间 id

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---

  `opts`

  Object

  <optional>

  随机加入房间选项

  ###### Properties

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `matchProperties` | Object | <optional> | 匹配属性，默认值为 null

#### pauseMessageQueue() → {void}

  暂停消息队列处理

  ##### Returns:

  void

#### async reconnect() [async]

  重新连接

#### async reconnectAndRejoin() [async]

  重新连接并自动加入房间

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

  重新加入房间

  ##### Parameters:

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

#### async removeRoomExpectedUserIds(expectedUserIds) [async]

  移除房间占位玩家 Id 列表

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `expectedUserIds` | * | 移除的玩家 Id 列表

#### resumeMessageQueue() → {void}

  恢复消息队列处理

  ##### Returns:

  void

#### 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 setRoomExpectedUserIds(expectedUserIds) [async]

  设置房间占位玩家 Id 列表

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `expectedUserIds` | * | 玩家 Id 列表

#### async setRoomMaxPlayerCount(count) [async]

  设置房间允许的最大玩家数量

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `count` | * | 数量

#### async setRoomOpen(open) [async]

  设置房间开启 / 关闭

  ##### Parameters:

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

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

  设置房间可见 / 不可见

  ##### Parameters:

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