Members

constant CreateRoomFlag :Number

创建房间标识
Properties:
Name Type Description
FixedMaster Number Master 掉线后固定 Master
MasterUpdateRoomProperties Number 只允许 Master 设置房间属性

constant Event :String

事件
Properties:
Name Type Description
CONNECTED String
CONNECT_FAILED String
DISCONNECTED String
LOBBY_JOINED String
LOBBY_LEFT String
LOBBY_ROOM_LIST_UPDATED String
ROOM_CREATED String
ROOM_CREATE_FAILED String
ROOM_JOINED String
ROOM_JOIN_FAILED String
PLAYER_ROOM_JOINED String
PLAYER_ROOM_LEFT String
PLAYER_ACTIVITY_CHANGED String
MASTER_SWITCHED String
ROOM_SYSTEM_PROPERTIES_CHANGED String
ROOM_OPEN_CHANGED String
ROOM_VISIBLE_CHANGED String
ROOM_LEFT String
ROOM_KICKED String
ROOM_CUSTOM_PROPERTIES_CHANGED String
PLAYER_CUSTOM_PROPERTIES_CHANGED String
CUSTOM_EVENT String
ERROR String

constant LogLevel

日志级别

constant ReceiverGroup :Number

接收组枚举
Properties:
Name Type Description
Others Number 其他人(除了自己之外的所有人)
All Number 所有人(包括自己)
MasterClient Number 主机客户端

Methods

deserializeObject(bytes)

反序列化 object
Parameters:
Name Type Description
bytes * 字节数组

registerType(type, typeId, serializeMethod, deserializeMethod)

注册自定义类型的序列化
Parameters:
Name Type Description
type * 类型
typeId number 类型 Id
serializeMethod function 序列化方法
deserializeMethod function 反序列化方法

serializeObject(obj)

序列化 object
Parameters:
Name Type Description
obj * 要序列化的 object

setAdapters(newAdapters)

设置适配器
Parameters:
Name Type Description
newAdapters Object
Properties
Name Type Description
WebSocketAdapter function WebSocket 适配器,Cocos Creator 打包 android 平台时需要传入 CA 证书