Room

房间类

Constructor

new Room()

Members

readonly customProperties :Object

获取自定义属性

readonly expectedUserIds :Array.<String>

邀请的好友 ID 列表

readonly master :Player

获取房主

readonly masterId :Number

房间主机玩家 ID

readonly maxPlayerCount :Number

房间允许的最大玩家数量

readonly name :String

房间名称

readonly opened :Boolean

房间是否开启

readonly playerList :Array.<Player>

获取房间内的玩家列表

readonly visible :Boolean

房间是否可见

Methods

getPlayer(actorId) → {Player}

根据 actorId 获取 Player 对象
Parameters:
Name Type Description
actorId Number 玩家在房间中的 Id
Returns:
Player

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 leave() [async]

离开房间

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 setCustomProperties(properties, optsopt) [async]

设置房间的自定义属性
Parameters:
Name Type Attributes Description
properties Object 自定义属性
opts Object <optional>
设置选项
Properties
Name Type Attributes Description
expectedValues Object <optional>
期望属性,用于 CAS 检测

async setMaster(newMasterId) [async]

设置房主
Parameters:
Name Type Description
newMasterId Number 新房主 ID

async setOpened(opened) [async]

设置房间开启 / 关闭
Parameters:
Name Type Description
opened Boolean 是否开启

async setVisible(visible) [async]

设置房间可见 / 不可见
Parameters:
Name Type Description
visible Boolean 是否可见