Commit f34df367 authored by limingzhe's avatar limingzhe

fix: key

parent d40f2950
{"ver":"1.1.2","uuid":"c35bb2f6-f24a-4850-ae44-643f2fdc7541","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}} {
\ No newline at end of file "ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
/**
* 可匹配房间列表信息
* @param rooms - 单次请求的房间列表
* @param count - 所有房间的总数
* @param offset - 偏移量,作为下一次查询请求的入参
* @param hasNext - 是否有下一页 0:无 1:有
* @public
*/
export declare interface AvailableRoomsInfo {
rooms: RoomInfo[];
count: number;
offset: string | number;
hasNext: 0 | 1;
}
/**
* Base 类
* @public
*/
export declare class Base {
protected get state(): StateCode;
protected get serverEventCode(): ServerEventCode;
protected get appId(): string;
protected get openId(): string;
protected get serviceToken(): string;
get playerId(): string;
get lastRoomId(): string;
get roomId(): string;
get groupId(): string;
protected constructor();
protected setState(state: StateCode): void;
protected setServerEvent(code: ServerEventCode, param?: string): void;
protected setAppId(id: string): void;
protected setOpenId(id: string): void;
protected setServiceToken(token: string): void;
protected setPlayerId(id: string): void;
protected setLastRoomId(roomId: string): void;
protected setRoomId(id: string): void;
protected setGroupId(id: string): void;
protected onStateChange(latter: StateCode, former: StateCode): void;
protected onServerEventChange(latter: ServerEvent, former: ServerEvent): void;
}
/**
* 客户端类
* @public
*/
export declare class Client extends Base {
private _auth;
private _room;
private _group;
private _pollInterval;
private _isMatching;
private _isCancelMatch;
private _loginTimestamp;
/**
* 获取对应房间实例
* @readonly
*/
get room(): Room | null;
/**
* 获取对应队伍实例
* @readonly
*/
get group(): Group | null;
/**
* 获取玩家登录时间戳
* @readonly
*/
get loginTimestamp(): number;
/**
* 创建客户端
* @param config - 创建客户端参数
*/
constructor(config: ClientConfig);
/**
* 初始化客户端
* @remarks 必须先初始化客户端,才能创建/加入/匹配房间
*/
init(): Promise<Client>;
/**
* 创建房间
* @remarks 创建成功也意味着加入了该房间
* @param createRoomConfig - 房间信息参数
* @param playerConfig - 玩家信息参数
*/
createRoom(createRoomConfig: CreateRoomConfig, playerConfig?: PlayerConfig): Promise<Room>;
/**
* 创建队伍
* @remarks 创建成功也意味着加入了该队伍
* @param groupConfig - 队伍信息参数
* @param playerConfig - 玩家信息参数
*/
createGroup(groupConfig: CreateGroupConfig, playerConfig?: PlayerConfig): Promise<Group>;
/**
* 加入房间
* @param roomIdentity - 房间身份标识(房间Id或者房间Code)
* @param playerConfig - 玩家信息参数
*/
joinRoom(roomIdentity: string, playerConfig?: PlayerConfig): Promise<Room>;
/**
* 根据队伍ID加入队伍
* @param groupId - 队伍 ID
* @param playerConfig - 玩家信息参数
*/
joinGroup(groupId: string, playerConfig?: PlayerConfig): Promise<Group>;
/**
* 离开房间
*/
leaveRoom(): Promise<Client>;
/**
* 解散房间
* @remarks 房主才能解散房间
*/
dismissRoom(): Promise<Client>;
/**
* 离开队伍
*/
leaveGroup(): Promise<Client>;
/**
* 解散队伍
* @remarks 队长才能解散队伍
*/
dismissGroup(): Promise<Client>;
/**
* 删除队伍实例
* @remarks 队员收到队伍解散通知后清空本地队伍信息
*/
removeGroup(): void;
/**
* 获取可匹配房间列表
*/
getAvailableRooms(getAvailableRoomsConfig: GetAvailableRoomsConfig): Promise<AvailableRoomsInfo>;
/**
* 房间匹配
* @param matchRoomConfig - 房间匹配参数
* @param playerConfig - 玩家信息参数
*/
matchRoom(matchRoomConfig: MatchRoomConfig, playerConfig?: PlayerConfig): Promise<Room>;
/**
* 在线匹配
* @param matchPlayerConfig - 在线匹配参数
* @param playerConfig - 玩家信息参数
*/
matchPlayer(matchPlayerConfig: MatchPlayerConfig, playerConfig?: PlayerConfig): Promise<Room>;
/**
* 组队匹配
* @param matchGroupConfig - 组队匹配参数
* @param playerConfig - 玩家信息参数
* @remarks 队长才能主动发起组队匹配,队员通过广播通知被动调起组队匹配
*/
matchGroup(matchGroupConfig: MatchGroupConfig, playerConfig?: PlayerConfig): Promise<Room>;
/**
* 取消匹配
* @remarks 组队匹配模式中,当前只有队长可以取消匹配
*/
cancelMatch(): void;
/**
* 取消匹配
*/
private requestCancelMatch;
/**
* 轮询匹配
*/
private matchPolling;
protected onStateChange(state: StateCode, former: StateCode): void;
private checkInit;
private checkCreateOrJoin;
private checkGroupCreateOrJoin;
private checkLeaveOrdismiss;
private checkGroupLeaveOrdismiss;
private checkCreateRoomConfig;
private checkCreateGroupConfig;
private checkJoinRoomConfig;
private checkMatching;
}
/**
* Client 类构造方法参数
* @param clientId - 客户端ID
* @param clientSecret - 客户端密钥
* @param appId - 应用ID
* @param openId - 玩家ID
* @param createSignature - 签名函数
* @public
*/
export declare interface ClientConfig {
clientId: string;
clientSecret: string;
openId: string;
appId: string;
createSignature?: CreateSignature;
}
/**
* 创建队伍方法参数
* @param maxPlayers - 队伍最大支持人数
* @param groupName - 队伍名称
* @param customGroupProperties - 队伍自定义属性
* @param isLock - 是否禁止加入 0:不禁止 1:禁止 默认0
* @param isPersistent - 是否持久化 0:不持久化 1:持久化 默认0
* @public
*/
export declare interface CreateGroupConfig {
maxPlayers: number;
groupName?: string;
customGroupProperties?: string;
isLock?: number;
isPersistent?: number;
}
/**
* 创建房间方法参数
* @param maxPlayers - 房间最大支持人数
* @param isPrivate - 是否私有
* @param roomType - 房间类型
* @param roomName - 房间名称
* @param matchParams - 房间匹配属性
* @param customRoomProperties - 房间自定义属性
* @public
*/
export declare interface CreateRoomConfig {
maxPlayers: number;
isPrivate?: number;
roomType?: string;
roomName?: string;
matchParams?: Record<string, string>;
customRoomProperties?: string;
}
/**
* 签名函数
* @public
*/
export declare type CreateSignature = () => Promise<Signature>;
/**
* 错误码
* @public
*/
export declare const enum ErrorCode {
COMMON_OK = 0,
COMMON_ERR = -1,
COMMON_INVALID_TOKEN = 2,
COMMON_REQUEST_PARAM_ERR = 1001,
DATABASE_OPERATION_ERR = 1002,
DCS_OPERATION_ERR = 1003,
FAILED_TO_VERIFY_THE_INTERFACE_SIGNATURE = 1011,
REPEAT_RUQUEST = 4003,
TOKEN_AUTH_FAILED = 100103,
SERVICE_NOT_ENABLED = 100104,
PLAYER_INFO_MIASSING = 100105,
PROJECT_NOT_EXIST = 100108,
QUERY_APP_INFO_FROM_AGC = 100112,
APP_NOT_BELONG_CURRENT_PROJECT = 100113,
INVALID_APP_SIGNATURE_VERIFICATION_PARAMETER = 100114,
FAILED_TO_VERIFY_THE_APP = 100115,
ROOM_PLAYER_NOT_IN_ROOM = 101101,
PLAYER_AND_ROOM_MISMATCH = 101102,
ROOM_INFO_NOT_EXIST = 101103,
CANNOT_DESTORY_ROOM_IN_GAME = 101104,
PLAYER_NOT_IN_CURRENT_ROOM = 101105,
ENTERED_ROOM_OR_NOT_EXIST = 101106,
PLAYERS_EXCEEDS_ROOM_MAX = 101107,
PLAYER_INFO_NOT_EXIST = 101108,
ROOM_OWNER_AND_PLAYER_MISMATCH = 101109,
GENERATE_SECURE_RANDOM_NUM_FAILED = 101110,
GET_SIGNATURE_INFO_FAILED = 101111,
CREATE_GRPC_CHANNEL_FAILED = 101112,
MAXPLAYER_TOO_LARGE = 101113,
ROOM_STARTED_FRAME_SYNC = 101114,
ROOM_STOPPED_FRAME_SYNC = 101115,
OTHER_PLAYER_OFFLINE = 101116,
INVALID_ROOM = 101117,
FRAME_SYNC_OPERATION_IS_INVALID_ROOM_STATE = 101118,
FRAME_SYNC_OPERATION_IS_INVALID_PLAYER_STATE = 101119,
INVALID_ROOM_STATUS = 101120,
REPEATS_PLAYER_ID = 101121,
PARSE_TIME_FAILED = 101122,
TOO_MANY_MATCHING_PARAMETERS = 101123,
PLAYER_STATUS_CONNOT_MODIFY = 101124,
ROOM_OWNER_STATUS_CANNOT_BE_KICKED = 101125,
PLAYER_INFO_CANNOT_EMPTY = 101126,
SOME_PLAYER_DADABASES_NOT_EXIST = 101127,
PLAYERS_NUMBER_EXCEEDS_THE_LIMIT = 101128,
THE_PLAYER_NOT_EXIST_DADABASES = 101129,
THE_PLAYER_ALREADY_IN_THE_ROOM = 101130,
ROUTE_INFO_CANNOT_BE_FOUND = 101131,
PLAYER_NOT_IN_CURRENT_GROUP = 101201,
GROUP_NOT_EXIST = 101202,
PLAYERS_ALREADY_IN_OTHER_GROUP = 101203,
THE_GROUP_CONNOT_BE_DISBANDED = 101204,
THE_PLAYER_NOT_CURRENT_GROUP_LEADER = 101205,
CURRENT_GROUP_IS_LOCKED = 101206,
CURRENT_GROUP_IS_FULL = 101207,
NEW_PLAYER_NOT_IN_GROUP = 101208,
ROOM_NOT_BEGIN_FRAME_SYNC = 102003,
PLAYER_NOT_IN_ROOM = 102005,
ROOM_NOT_EXIST = 102008,
PRASE_MESSAGE_FAILED = 102009,
UNSUPPORTED_MESSAGE_TYPE = 102013,
REQUEST_FRAME_NUMBER_OVERRUN = 102014,
LOGIN_BUSY = 103001,
LOGIN_AUTH_FAIL = 103002,
CLIENT_TRAFFIC_CONTROL = 103003,
NOT_LOGGED_IN = 103004,
EXCEED_MAX_CONNECTIONSS = 103006,
ROOM_MATCH_FAILED = 104101,
ROOM_MATCHING = 104102,
ROOM_MATCH_TIMEOUT = 104103,
PLAYER_MATCH_FAILED = 104201,
PLAYER_MATCHING = 104202,
PLAYER_MATCH_TIMEOUT = 104203,
PLAYER_MATCH_CANCEL_NO_PERMISSION = 104204,
PLAYER_MATCH_CANCELED = 104205,
PLAYER_MATCH_CANCEL_WHEN_SUCCESS = 104206,
PLAYER_MATCH_GET_RULE_FAIL = 104207,
PLAYER_MATCH_ROOM_IS_NULL = 104208,
PLAYER_MATCH_INVALID_TEAM = 104209,
SDK_NOT_IN_GROUP = 80001,
SDK_GROUP_NAME_TOO_LONG = 80002,
SDK_NO_PERMISSION_UPDATE_GROUP = 80003,
SDK_IN_GROUP = 80004,
SDK_UNINIT = 90001,
SDK_NOT_IN_ROOM = 90002,
SDK_IN_ROOM = 90003,
SDK_NOT_ROOM_OWNER = 90004,
SDK_NOT_IN_FRAME_SYNC = 90005,
SDK_IN_FRAME_SYNC = 90006,
SDK_INVALID_ROOM_IDENTITY = 90007,
SDK_IN_MATCHING = 90008,
SDK_NOT_IN_MATCHING = 90009,
SDK_IN_Requesting = 90010,
SDK_GROUP_MEMBERS_ERROR = 90011,
SDK_ROOM_NAME_TOO_LONG = 10001
}
/**
* 事件触发器
* @public
*/
export declare class EventEmitter<T extends (...args: any[]) => any> {
handlers: Array<T>;
on(handler: T): this;
emit(...args: FunctionParam<T>): void;
off(handler: T): void;
clear(): void;
}
/**
* 附加信息
* @public
*/
export declare interface FrameExtInfo {
seed: number;
}
/**
* 帧数据信息
* @public
*/
export declare interface FrameInfo extends FramePlayerInfo {
data: string[];
timestamp: number;
}
/**
* 帧数据玩家信息
* @public
*/
export declare interface FramePlayerInfo {
playerId: string;
}
/**
* 函数参数类型
* @public
*/
export declare type FunctionParam<T> = T extends (...args: infer P) => any ? P : never;
/**
* 获取可匹配房间列表参数
* @param roomType - 房间类型
* @param offset - 偏移量,使用房间的createTime作为每次请求的标记,第一次请求时为0
* @param limit - 单次请求获取的房间数量,不选时服务端默认为20
* @public
*/
export declare interface GetAvailableRoomsConfig {
roomType?: string;
offset?: number | string;
limit?: number;
}
/**
* 自定义错误类
* @public
*/
export declare class GOBEError extends Error {
code: number;
constructor(code: number, message?: string);
}
/**
* 队伍类
* @public
*/
export declare class Group extends Base {
onJoin: {
(this: any, cb: (serverEvent: ServerEvent) => void): EventEmitter<(serverEvent: ServerEvent) => void>;
emit(serverEvent: ServerEvent): void;
off(cb: (serverEvent: ServerEvent) => void): void;
clear(): void;
};
onLeave: {
(this: any, cb: (serverEvent: ServerEvent) => void): EventEmitter<(serverEvent: ServerEvent) => void>;
emit(serverEvent: ServerEvent): void;
off(cb: (serverEvent: ServerEvent) => void): void;
clear(): void;
};
onDismiss: {
(this: any, cb: (serverEvent: ServerEvent) => void): EventEmitter<(serverEvent: ServerEvent) => void>;
emit(serverEvent: ServerEvent): void;
off(cb: (serverEvent: ServerEvent) => void): void;
clear(): void;
};
onUpdate: {
(this: any, cb: (serverEvent: ServerEvent) => void): EventEmitter<(serverEvent: ServerEvent) => void>;
emit(serverEvent: ServerEvent): void;
off(cb: (serverEvent: ServerEvent) => void): void;
clear(): void;
};
onMatchStart: {
(this: any, cb: (serverEvent: ServerEvent) => void): EventEmitter<(serverEvent: ServerEvent) => void>;
emit(serverEvent: ServerEvent): void;
off(cb: (serverEvent: ServerEvent) => void): void;
clear(): void;
};
private config;
private _player;
private _client;
/**
* 队伍 ID
*/
get id(): string;
/**
* 队伍名称
*/
get groupName(): string;
/**
* 队伍最大人数
*/
get maxPlayers(): number;
/**
* 队长 ID
*/
get ownerId(): string;
/**
* 队伍自定义属性
*/
get customGroupProperties(): string;
/**
* 是否禁止加入 0:不禁止 1:禁止 默认0
*/
get isLock(): number;
/**
* 是否持久化 0:不持久化 1:持久化 默认0
*/
get isPersistent(): number;
/**
* 队伍玩家列表
*/
get players(): PlayerInfo[];
/**
* 玩家自己
*/
get player(): Player;
/**
* 队伍
* @param config - 创建客户端参数
*/
constructor(client: Client, config: GroupInfo);
/**
* 队伍信息查询
*/
query(): Promise<Group>;
/**
* 离开队伍
*/
leave(): Promise<void>;
/**
* 解散队伍
* @remarks 队长才能解散队伍
*/
dismiss(): Promise<void>;
/**
* 更新队伍信息
* @remarks 队长才能更新队伍信息
* @param config - 更新队伍信息参数
*/
updateGroup(config: UpdateGroupConfig): Promise<void>;
private checkUpdatePermission;
protected onServerEventChange(serverEvent: ServerEvent): Promise<void>;
removeAllListeners(): void;
}
/**
* 队伍信息
* @param groupId - 队伍id
* @param groupName - 队伍名称
* @param maxPlayers - 最大玩家数
* @param ownerId - 队长ID
* @param customGroupProperties - 队伍自定义属性
* @param isLock - 是否禁止加入 0:不禁止 1:禁止 默认0
* @param isPersistent - 是否持久化 0:不持久化 1:持久化 默认0
* @param players - 队伍内玩家列表
* @public
*/
export declare interface GroupInfo {
groupId: string;
groupName: string;
maxPlayers: number;
ownerId: string;
customGroupProperties: string;
isLock: number;
isPersistent: number;
players: PlayerInfo[];
}
/**
* 组队匹配参数
* @param playerInfos - 带匹配规则的玩家信息列表
* @param teamInfo - 带匹配规则队伍信息,非对称匹配场景必填,存放队伍参数
* @param matchCode - 匹配规则编号
* @public
*/
export declare interface MatchGroupConfig {
playerInfos: MatchPlayerInfoParam[];
teamInfo?: MatchTeamInfoParam;
matchCode: string;
}
/**
* 在线匹配参数
* @param playerInfo - 带匹配规则的玩家信息
* @param teamInfo - 带匹配规则队伍信息,非对称匹配场景必填,存放队伍参数
* @param matchCode - 匹配规则编号
* @public
*/
export declare interface MatchPlayerConfig {
playerInfo: MatchPlayerInfoParam;
teamInfo?: MatchTeamInfoParam;
matchCode: string;
}
/**
* 带匹配规则的玩家信息
* @param matchParams - 自定义匹配参数
* @public
*/
export declare interface MatchPlayerInfoParam {
playerId: string;
matchParams: Record<string, number>;
}
/**
* 房间匹配参数
* @param matchParams - 自定义匹配参数,最多支持5条匹配规则
* @param maxPlayers - 房间最大支持人数
* @param roomType - 房间类型
* @param customRoomProperties - 自定义房间属性
* @remarks maxPlayers,roomType,customRoomProperties用于找不到匹配房间时创建房间
* @public
*/
export declare interface MatchRoomConfig {
matchParams: Record<string, string>;
maxPlayers: number;
roomType?: string;
customRoomProperties?: string;
}
/**
* 带匹配规则队伍信息,非对称匹配场景必填,存放队伍参数
* @param matchParams - 自定义匹配参数
* @public
*/
export declare interface MatchTeamInfoParam {
matchParams: Record<string, number>;
}
/**
* 玩家类
* @public
*/
export declare class Player extends Base {
customStatus?: number;
customProperties?: string;
constructor(customStatus?: number, customProperties?: string);
/**
* 更新玩家自定义状态
*/
updateCustomStatus(status: number): Promise<Player>;
}
/**
* 玩家自定义参数
* @param customPlayerStatus - 玩家自定义状态
* @param customPlayerProperties - 玩家自定义属性
* @public
*/
export declare interface PlayerConfig {
customPlayerStatus?: number;
customPlayerProperties?: string;
}
/**
* 玩家信息
* @param playerId - 玩家ID
* @param status - 玩家状态 0:空闲;1:房间中;2:帧同步中;3:离线
* @param customPlayerStatus - 自定义玩家状态
* @param customPlayerProperties - 自定义玩家属性
* @param teamId - 玩家teamId
* @public
*/
export declare interface PlayerInfo {
readonly playerId: string;
readonly status?: number;
readonly customPlayerStatus?: number;
readonly customPlayerProperties?: string;
readonly teamId?: string;
}
/**
* 房间内消息码
* @public
*/
export declare const enum Protocol {
LOGIN = 0,
LOGIN_ACK = 1,
HEARTBEAT = 2,
HEARTBEAT_ACK = 3,
CLIENT_SEND_FRAMEDATA = 4,
CLIENT_SEND_FRAMEDATA_ACK = 5,
QUERY_FRAMEDATA = 6,
QUERY_FRAMEDATA_ACK = 7,
FRAMESYNC_STARTED = 8,
FRAMESYNC_STOPED = 9,
BROADCAST_FRAMEDATA = 10,
QUERY_FRAMEDATA_RESULT = 17,
JOIN_ROOM = 12,
LEAVE_ROOM = 13,
CONNECTED = 14,
DISCONNECTED = 15,
ROOM_DISMISS = 16
}
/**
* 基于「线性同余」的伪随机数生成器
* @public
*/
export declare class RandomUtils {
private mask;
private m;
private a;
private seed;
constructor(seed: number);
getNumber(): number;
}
/**
* 房间类
* @public
*/
export declare class Room extends Base {
onJoin: {
(this: any, cb: (player: FramePlayerInfo) => any): EventEmitter<(player: FramePlayerInfo) => any>;
emit(player: FramePlayerInfo): void;
off(cb: (player: FramePlayerInfo) => any): void;
clear(): void;
};
onLeave: {
(this: any, cb: (player: FramePlayerInfo) => any): EventEmitter<(player: FramePlayerInfo) => any>;
emit(player: FramePlayerInfo): void;
off(cb: (player: FramePlayerInfo) => any): void;
clear(): void;
};
onDismiss: {
(this: any, cb: () => any): EventEmitter<() => any>;
emit(): void;
off(cb: () => any): void;
clear(): void;
};
onDisconnect: {
(this: any, cb: (player: FramePlayerInfo, event?: CloseEvent | undefined) => any): EventEmitter<(player: FramePlayerInfo, event?: CloseEvent | undefined) => any>;
emit(player: FramePlayerInfo, event?: CloseEvent | undefined): void;
off(cb: (player: FramePlayerInfo, event?: CloseEvent | undefined) => any): void;
clear(): void;
};
onStartFrameSync: {
(this: any, cb: () => any): EventEmitter<() => any>;
emit(): void;
off(cb: () => any): void;
clear(): void;
};
onStopFrameSync: {
(this: any, cb: () => any): EventEmitter<() => any>;
emit(): void;
off(cb: () => any): void;
clear(): void;
};
onRecvFrame: {
(this: any, cb: (msg: ServerFrameMessage | ServerFrameMessage[]) => any): EventEmitter<(msg: ServerFrameMessage | ServerFrameMessage[]) => any>;
emit(msg: ServerFrameMessage | ServerFrameMessage[]): void;
off(cb: (msg: ServerFrameMessage | ServerFrameMessage[]) => any): void;
clear(): void;
};
onRequestFrameError: {
(this: any, cb: (error: GOBEError) => any): EventEmitter<(error: GOBEError) => any>;
emit(error: GOBEError): void;
off(cb: (error: GOBEError) => any): void;
clear(): void;
};
private connection;
private config;
private frameId;
private readonly frameRequestMaxSize;
private frameRequesting;
private frameRequestSize;
private frameRequestList;
private autoFrameRequesting;
private autoFrameRequestCacheList;
private endpoint;
private wsHeartbeatTimer;
private _isSyncing;
private _player;
private _client;
/**
* 房间 ID
*/
get id(): string;
/**
* 房间类型
*/
get roomType(): string;
/**
* 房间名称
*/
get roomName(): string;
/**
* 房间的短码
*/
get roomCode(): string;
/**
* 房间自定义属性
*/
get customRoomProperties(): string;
/**
* 房主 ID
*/
get ownerId(): string;
/**
* 房间最大人数
*/
get maxPlayers(): number;
/**
* 房间玩家列表
*/
get players(): PlayerInfo[];
/**
* 路由信息
*/
get router(): RouterInfo;
/**
* 0:公开房间,1:私有房间
*/
get isPrivate(): number;
/**
* 创建时间
*/
get createTime(): number;
/**
* 玩家自己
*/
get player(): Player;
/**
* 房间是否处于帧同步
*/
get isSyncing(): boolean;
/**
* 房间
* @param config - 创建客户端参数
*/
constructor(client: Client, config: RoomInfo);
/**
* websocket 建链
* @param endpoint - 接入地址
*/
connect(routerAddr: string, ticket: string): void;
/**
* 发送帧数据
* @param frameData - 帧数据
*/
sendFrame(frameData: string | string[]): void;
/**
* 请求补帧
* @param beginFrameId - 起始帧号
* @param size - 请求帧号
*/
requestFrame(beginFrameId: number, size: number): void;
/**
* 移除所有事件监听
*/
removeAllListeners(): void;
/**
* 重连
*/
reconnect(): Promise<void>;
/**
* 开始帧同步
*/
startFrameSync(): Promise<void>;
/**
* 结束帧同步
*/
stopFrameSync(): Promise<void>;
/**
* 玩家房间信息查询
*/
update(): Promise<Room>;
/**
* 离开房间
*/
leave(): Promise<void>;
/**
* 解散房间
* @remarks 房主才能解散房间
*/
dismiss(): Promise<void>;
/**
* 移除房间内玩家
* @param playerId - 被移除出的玩家ID
* @remarks 只有房主有权限移除其他玩家
* @remarks 房间在帧同步中,不能移除其他玩家
*/
removePlayer(playerId: string): Promise<void>;
private onMessageCallback;
private clearRequestFrame;
private startWSHeartbeat;
private doWSHeartbeat;
private stopWSHeartbeat;
private buildEndpoint;
private checkInSync;
private checkNotInSync;
private checkNotInRequesting;
}
/**
* 房间信息
* @public
* @param appId - 游戏ID
* @param roomId - 房间ID
* @param roomType - 房间类型
* @param roomCode - 房间的短码
* @param roomName - 房间名称
* @param roomStatus - 房间状态 0:空闲,1:帧同步中,2:待回收
* @param customRoomProperties - 房间自定义属性
* @param ownerId - 房主ID
* @param maxPlayers - 房间最大支持人数
* @param players - 房间内玩家
* @param router - 路由信息
* @param isPrivate - 是否私有
* @param createTime - 创建时间
*/
export declare interface RoomInfo {
appId: string;
roomId: string;
roomType: string;
roomCode: string;
roomName: string;
roomStatus: number;
customRoomProperties: string;
ownerId: string;
maxPlayers: number;
players: PlayerInfo[];
router: RouterInfo;
isPrivate: number;
createTime: number;
}
/**
* 路由信息
* @public
*/
export declare interface RouterInfo {
routerId: number;
routerType: number;
routerAddr: string;
}
/**
* 服务端 ACK 消息
* @public
*/
export declare interface ServerAckMessage {
rtnCode: number;
msg: string;
}
/**
* 服务端事件
* @param eventType - 1:匹配开始;2:匹配成功;3:匹配失败;4:匹配取消;5:匹配超时;6:加入小队;7:离开小队;8:解散小队;9:更新小队;
* @param eventParam - 事件相关信息
* @public
*/
export declare interface ServerEvent {
eventType: ServerEventCode;
eventParam?: string;
}
/**
* 服务端事件码
* @public
*/
export declare const enum ServerEventCode {
DEFAULT = 0,
MATCH_START = 1,
MATCH_SUCCESS = 2,
MATCH_FAILED = 3,
MATCH_CANCEL = 4,
MATCH_TIMEOUT = 5,
JOIN_GROUP = 6,
LEAVE_GROUP = 7,
DISMISS_GROUP = 8,
UPDATE_GROUP = 9
}
/**
* 服务端推送消息
* @public
*/
export declare interface ServerFrameMessage {
currentRoomFrameId: number;
frameInfo: FrameInfo[];
ext: FrameExtInfo;
}
/**
* 初始化签名
* @param sign - 签名
* @param nonce - 随机正整数
* @param timestamp - 时间戳(秒)
* @public
*/
export declare interface Signature {
sign: string;
nonce: number;
timestamp: number;
}
/**
* SDK 状态码
* @public
*/
export declare const enum StateCode {
UNINITIALIZED = 0,
INITIALIZED = 1,
INROOM = 2,
SYNCING = 3,
ENTER_ROOM = 4,
LEAVE_ROOM = 5,
ENTER_SYNCING = 6,
EXIT_SYNCING = 7
}
/**
* 更新队伍信息参数
* @param groupName - 队伍名称
* @param ownerId - 队长ID
* @param customGroupProperties - 队伍自定义属性
* @param isLock - 是否禁止加入 0:不禁止 1:禁止 默认0
* @public
*/
export declare interface UpdateGroupConfig {
groupName?: string;
ownerId?: string;
customGroupProperties?: string;
isLock?: number;
}
export { }
export as namespace GOBE
/*gobe_v1.1.5*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).GOBE={})}(this,(function(exports){"use strict";class EventEmitter{constructor(){this.handlers=[]}on(e){return this.handlers.push(e),this}emit(...e){this.handlers.forEach((t=>t.apply(this,e)))}off(e){const t=this.handlers.indexOf(e);this.handlers[t]=this.handlers[this.handlers.length-1],this.handlers.pop()}clear(){this.handlers=[]}}function createSignal(){const e=new EventEmitter;function t(t){return e.on(t)}return t.emit=(...t)=>e.emit(...t),t.off=t=>e.off(t),t.clear=()=>e.clear(),t}class Store{constructor(){this.stateEmitter=new EventEmitter,this.serverEventEmitter=new EventEmitter,this._state={state:0,openId:"",appId:"",serviceToken:"",playerId:"",lastRoomId:"",roomId:"",groupId:""},this._serverEventCode=0}get state(){return this._state.state}get serverEventCode(){return this._serverEventCode}get appId(){return this._state.appId}get serviceToken(){return this._state.serviceToken}get playerId(){return this._state.playerId}get lastRoomId(){return this._state.lastRoomId}get roomId(){return this._state.roomId}get groupId(){return this._state.groupId}get openId(){return this._state.openId}setStateAction(e){if(e==this._state.state)return;const t=this._state.state;this._state.state=e,this.stateEmitter.emit(e,t)}setServerEventAction(e,t){const r={eventType:this._serverEventCode,eventParam:t};this._serverEventCode=e;const o={eventType:e,eventParam:t};this.serverEventEmitter.emit(o,r)}setAppIdAction(e){this._state.appId=e}setOpenIdAction(e){this._state.openId=e}setServiceTokenAction(e){this._state.serviceToken=e}setPlayerIdAction(e){this._state.playerId=e}setLastRoomIdAction(e){this._state.lastRoomId=e}setRoomIdAction(e){this._state.roomId=e}setGroupIdAction(e){this._state.groupId=e}addStateListener(e){this.stateEmitter.on(e)}addServerEventListener(e){this.serverEventEmitter.on(e)}}var store=new Store;class Base{get state(){return store.state}get serverEventCode(){return store.serverEventCode}get appId(){return store.appId}get openId(){return store.openId}get serviceToken(){return store.serviceToken}get playerId(){return store.playerId}get lastRoomId(){return store.lastRoomId}get roomId(){return store.roomId}get groupId(){return store.groupId}constructor(){store.addStateListener(((...e)=>this.onStateChange(...e))),store.addServerEventListener(((...e)=>this.onServerEventChange(...e)))}setState(e){store.setStateAction(e)}setServerEvent(e,t=""){store.setServerEventAction(e,t)}setAppId(e){store.setAppIdAction(e)}setOpenId(e){store.setOpenIdAction(e)}setServiceToken(e){store.setServiceTokenAction(e)}setPlayerId(e){store.setPlayerIdAction(e)}setLastRoomId(e){store.setLastRoomIdAction(e)}setRoomId(e){store.setRoomIdAction(e)}setGroupId(e){store.setGroupIdAction(e)}onStateChange(e,t){}onServerEventChange(e,t){}}function __awaiter(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))}class GOBEError extends Error{constructor(e,t){super(t),this.code=e,this.name="GOBE Error",Object.setPrototypeOf(this,new.target.prototype)}}const generateRequestId=()=>{var e;if("function"==typeof(null===(e=globalThis.crypto)||void 0===e?void 0:e.getRandomValues)){const e=new Uint32Array(1);return globalThis.crypto.getRandomValues(e)[0].toString()}return Math.random().toString().slice(2)};class Request{static post(e,t,r,o=!0){const n=/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?e:"https://gobe-drcn.game.dbankcloud.cn"+e;return new Promise(((i,s)=>{const a=new XMLHttpRequest;a.open("POST",n),a.setRequestHeader("Content-Type","application/json"),a.withCredentials=!1,a.timeout=Request.timeout;e.includes("gamex-edge-service")&&(a.setRequestHeader("sdkVersionCode","10105200"),a.setRequestHeader("serviceToken",store.serviceToken),a.setRequestHeader("appId",store.appId),a.setRequestHeader("requestId",generateRequestId())),r&&Object.entries(r).forEach((([e,t])=>a.setRequestHeader(e,t))),a.send(JSON.stringify(t)),a.onerror=function(e){s(e)},a.ontimeout=function(e){s(e)},a.onreadystatechange=function(){if(4==a.readyState)if(200==a.status){const e=JSON.parse(a.responseText);o&&0!=e.rtnCode&&s(new GOBEError(e.rtnCode,e.msg)),i(e)}else s({data:a.responseText,status:a.status,statusText:a.statusText,headers:a.getAllResponseHeaders(),request:a})}}))}}Request.timeout=5e3;class Auth extends Base{constructor(e,t,r){super(),this.clientId=e,this.clientSecret=t,this.createSignature=r}requestAccessToken(){return __awaiter(this,void 0,void 0,(function*(){const e=yield Request.post("https://connect-drcn.hispace.hicloud.com/agc/apigw/oauth2/v1/token",{grant_type:"client_credentials",client_id:this.clientId,client_secret:this.clientSecret,useJwt:0},{app_id:this.appId},!1);if("ret"in e)throw new Error(e.ret.msg);return e.access_token}))}requestServiceToken(e,t){return __awaiter(this,void 0,void 0,(function*(){return yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.player.login",cpAccessToken:e,clientId:this.clientId,openId:this.openId},t))}))}requestGameConfig(){return __awaiter(this,void 0,void 0,(function*(){return yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.config.param"})}))}login(){return __awaiter(this,void 0,void 0,(function*(){const e=yield this.requestAccessToken(),t=this.createSignature?yield this.createSignature():void 0,{serviceToken:r,playerId:o,lastRoomId:n,timeStamp:i}=yield this.requestServiceToken(e,t);this.setState(1),this.setServiceToken(r),this.setPlayerId(o),this.setLastRoomId(n);return{gameInfo:(yield this.requestGameConfig()).configParam,timeStamp:i}}))}}class Player extends Base{constructor(e,t){super(),this.customStatus=e,this.customProperties=t}updateCustomStatus(e){return __awaiter(this,void 0,void 0,(function*(){return yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.custom.player.status.update",customPlayerStatus:e}),this.customStatus=e,this}))}}class WebSocketTransport{constructor(e){this.events=e,this.ws=null}connect(e){var t,r,o,n;this.ws=new WebSocket(e,this.protocols),this.ws.binaryType="arraybuffer",this.ws.onopen=null!==(t=this.events.onopen)&&void 0!==t?t:null,this.ws.onmessage=null!==(r=this.events.onmessage)&&void 0!==r?r:null,this.ws.onclose=null!==(o=this.events.onclose)&&void 0!==o?o:null,this.ws.onerror=null!==(n=this.events.onerror)&&void 0!==n?n:null}send(e){var t,r;e instanceof ArrayBuffer?null===(t=this.ws)||void 0===t||t.send(e):null===(r=this.ws)||void 0===r||r.send(new Uint8Array(e).buffer)}close(e,t){var r;null===(r=this.ws)||void 0===r||r.close(e,t)}}class Connection{constructor(e=WebSocketTransport){this.events={},this.transport=new e(this.events)}connect(e){this.transport.connect(e)}send(e){this.transport.send(e)}close(e,t){this.transport.close(e,t)}}class Heartbeat extends Base{constructor(){super()}schedule(){this.execute()}execute(){[1,2,3].includes(this.state)?this.send().finally((()=>{this.delay(this.execute,4e3)})):this.delay(this.execute,5e3)}delay(e,t){setTimeout(e.bind(this),t)}send(e=this.state,t=this.roomId){return Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.event.notify",eventType:e,roomId:t}).then((e=>{if(e.events)for(const t of e.events)this.setServerEvent(t.eventType,t.eventParam)}))}}var heartbeat=new Heartbeat,commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},protobuf={exports:{}};(function(module){(function(undefined$1){!function(e,t,r){var o=function r(o){var n=t[o];return n||e[o][0].call(n=t[o]={exports:{}},r,n,n.exports),n.exports}(r[0]);o.util.global.protobuf=o,"function"==typeof undefined$1&&undefined$1.amd&&undefined$1(["long"],(function(e){return e&&e.isLong&&(o.util.Long=e,o.configure()),o})),module&&module.exports&&(module.exports=o)}({1:[function(e,t,r){t.exports=function(e,t){var r=new Array(arguments.length-1),o=0,n=2,i=!0;for(;n<arguments.length;)r[o++]=arguments[n++];return new Promise((function(n,s){r[o]=function(e){if(i)if(i=!1,e)s(e);else{for(var t=new Array(arguments.length-1),r=0;r<t.length;)t[r++]=arguments[r];n.apply(null,t)}};try{e.apply(t||null,r)}catch(e){i&&(i=!1,s(e))}}))}},{}],2:[function(e,t,r){var o=r;o.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),i=new Array(123),s=0;s<64;)i[n[s]=s<26?s+65:s<52?s+71:s<62?s-4:s-59|43]=s++;o.encode=function(e,t,r){for(var o,i=null,s=[],a=0,u=0;t<r;){var c=e[t++];switch(u){case 0:s[a++]=n[c>>2],o=(3&c)<<4,u=1;break;case 1:s[a++]=n[o|c>>4],o=(15&c)<<2,u=2;break;case 2:s[a++]=n[o|c>>6],s[a++]=n[63&c],u=0}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return u&&(s[a++]=n[o],s[a++]=61,1===u&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var a="invalid encoding";o.decode=function(e,t,r){for(var o,n=r,s=0,u=0;u<e.length;){var c=e.charCodeAt(u++);if(61===c&&s>1)break;if((c=i[c])===undefined$1)throw Error(a);switch(s){case 0:o=c,s=1;break;case 1:t[r++]=o<<2|(48&c)>>4,o=c,s=2;break;case 2:t[r++]=(15&o)<<4|(60&c)>>2,o=c,s=3;break;case 3:t[r++]=(3&o)<<6|c,s=0}}if(1===s)throw Error(a);return r-n},o.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},{}],3:[function(e,t,r){function o(){this._listeners={}}t.exports=o,o.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},o.prototype.off=function(e,t){if(e===undefined$1)this._listeners={};else if(t===undefined$1)this._listeners[e]=[];else for(var r=this._listeners[e],o=0;o<r.length;)r[o].fn===t?r.splice(o,1):++o;return this},o.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],o=1;o<arguments.length;)r.push(arguments[o++]);for(o=0;o<t.length;)t[o].fn.apply(t[o++].ctx,r)}return this}},{}],4:[function(e,t,r){function o(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),o=128===r[3];function n(e,o,n){t[0]=e,o[n]=r[0],o[n+1]=r[1],o[n+2]=r[2],o[n+3]=r[3]}function i(e,o,n){t[0]=e,o[n]=r[3],o[n+1]=r[2],o[n+2]=r[1],o[n+3]=r[0]}function s(e,o){return r[0]=e[o],r[1]=e[o+1],r[2]=e[o+2],r[3]=e[o+3],t[0]}function a(e,o){return r[3]=e[o],r[2]=e[o+1],r[1]=e[o+2],r[0]=e[o+3],t[0]}e.writeFloatLE=o?n:i,e.writeFloatBE=o?i:n,e.readFloatLE=o?s:a,e.readFloatBE=o?a:s}():function(){function t(e,t,r,o){var n=t<0?1:0;if(n&&(t=-t),0===t)e(1/t>0?0:2147483648,r,o);else if(isNaN(t))e(2143289344,r,o);else if(t>34028234663852886e22)e((n<<31|2139095040)>>>0,r,o);else if(t<11754943508222875e-54)e((n<<31|Math.round(t/1401298464324817e-60))>>>0,r,o);else{var i=Math.floor(Math.log(t)/Math.LN2);e((n<<31|i+127<<23|8388607&Math.round(t*Math.pow(2,-i)*8388608))>>>0,r,o)}}function r(e,t,r){var o=e(t,r),n=2*(o>>31)+1,i=o>>>23&255,s=8388607&o;return 255===i?s?NaN:n*(1/0):0===i?1401298464324817e-60*n*s:n*Math.pow(2,i-150)*(s+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,i),e.readFloatLE=r.bind(null,s),e.readFloatBE=r.bind(null,a)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),o=128===r[7];function n(e,o,n){t[0]=e,o[n]=r[0],o[n+1]=r[1],o[n+2]=r[2],o[n+3]=r[3],o[n+4]=r[4],o[n+5]=r[5],o[n+6]=r[6],o[n+7]=r[7]}function i(e,o,n){t[0]=e,o[n]=r[7],o[n+1]=r[6],o[n+2]=r[5],o[n+3]=r[4],o[n+4]=r[3],o[n+5]=r[2],o[n+6]=r[1],o[n+7]=r[0]}function s(e,o){return r[0]=e[o],r[1]=e[o+1],r[2]=e[o+2],r[3]=e[o+3],r[4]=e[o+4],r[5]=e[o+5],r[6]=e[o+6],r[7]=e[o+7],t[0]}function a(e,o){return r[7]=e[o],r[6]=e[o+1],r[5]=e[o+2],r[4]=e[o+3],r[3]=e[o+4],r[2]=e[o+5],r[1]=e[o+6],r[0]=e[o+7],t[0]}e.writeDoubleLE=o?n:i,e.writeDoubleBE=o?i:n,e.readDoubleLE=o?s:a,e.readDoubleBE=o?a:s}():function(){function t(e,t,r,o,n,i){var s=o<0?1:0;if(s&&(o=-o),0===o)e(0,n,i+t),e(1/o>0?0:2147483648,n,i+r);else if(isNaN(o))e(0,n,i+t),e(2146959360,n,i+r);else if(o>17976931348623157e292)e(0,n,i+t),e((s<<31|2146435072)>>>0,n,i+r);else{var a;if(o<22250738585072014e-324)e((a=o/5e-324)>>>0,n,i+t),e((s<<31|a/4294967296)>>>0,n,i+r);else{var u=Math.floor(Math.log(o)/Math.LN2);1024===u&&(u=1023),e(4503599627370496*(a=o*Math.pow(2,-u))>>>0,n,i+t),e((s<<31|u+1023<<20|1048576*a&1048575)>>>0,n,i+r)}}}function r(e,t,r,o,n){var i=e(o,n+t),s=e(o,n+r),a=2*(s>>31)+1,u=s>>>20&2047,c=4294967296*(1048575&s)+i;return 2047===u?c?NaN:a*(1/0):0===u?5e-324*a*c:a*Math.pow(2,u-1075)*(c+4503599627370496)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,i,4,0),e.readDoubleLE=r.bind(null,s,0,4),e.readDoubleBE=r.bind(null,a,4,0)}(),e}function n(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function i(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function s(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function a(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}t.exports=o(o)},{}],5:[function(require,module,exports){function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},{}],6:[function(e,t,r){t.exports=function(e,t,r){var o=r||8192,n=o>>>1,i=null,s=o;return function(r){if(r<1||r>n)return e(r);s+r>o&&(i=e(o),s=0);var a=t.call(i,s,s+=r);return 7&s&&(s=1+(7|s)),a}}},{}],7:[function(e,t,r){var o=r;o.length=function(e){for(var t=0,r=0,o=0;o<e.length;++o)(r=e.charCodeAt(o))<128?t+=1:r<2048?t+=2:55296==(64512&r)&&56320==(64512&e.charCodeAt(o+1))?(++o,t+=4):t+=3;return t},o.read=function(e,t,r){if(r-t<1)return"";for(var o,n=null,i=[],s=0;t<r;)(o=e[t++])<128?i[s++]=o:o>191&&o<224?i[s++]=(31&o)<<6|63&e[t++]:o>239&&o<365?(o=((7&o)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(o>>10),i[s++]=56320+(1023&o)):i[s++]=(15&o)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,i)),s=0);return n?(s&&n.push(String.fromCharCode.apply(String,i.slice(0,s))),n.join("")):String.fromCharCode.apply(String,i.slice(0,s))},o.write=function(e,t,r){for(var o,n,i=r,s=0;s<e.length;++s)(o=e.charCodeAt(s))<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=63&o|128):55296==(64512&o)&&56320==(64512&(n=e.charCodeAt(s+1)))?(o=65536+((1023&o)<<10)+(1023&n),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=63&o|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=63&o|128);return r-i}},{}],8:[function(e,t,r){var o=r;function n(){o.util._configure(),o.Writer._configure(o.BufferWriter),o.Reader._configure(o.BufferReader)}o.build="minimal",o.Writer=e(16),o.BufferWriter=e(17),o.Reader=e(9),o.BufferReader=e(10),o.util=e(15),o.rpc=e(12),o.roots=e(11),o.configure=n,n()},{10:10,11:11,12:12,15:15,16:16,17:17,9:9}],9:[function(e,t,r){t.exports=u;var o,n=e(15),i=n.LongBits,s=n.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function u(e){this.buf=e,this.pos=0,this.len=e.length}var c,l="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new u(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new u(e);throw Error("illegal buffer")},m=function(){return n.Buffer?function(e){return(u.create=function(e){return n.Buffer.isBuffer(e)?new o(e):l(e)})(e)}:l};function h(){var e=new i(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new i(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}u.create=m(),u.prototype._slice=n.Array.prototype.subarray||n.Array.prototype.slice,u.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return c;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return c}),u.prototype.int32=function(){return 0|this.uint32()},u.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},u.prototype.bool=function(){return 0!==this.uint32()},u.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},u.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},u.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=n.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},u.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=n.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},u.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},u.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},u.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},u.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},u._configure=function(e){o=e,u.create=m(),o._configure();var t=n.Long?"toLong":"toNumber";n.merge(u.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},{15:15}],10:[function(e,t,r){t.exports=i;var o=e(9);(i.prototype=Object.create(o.prototype)).constructor=i;var n=e(15);function i(e){o.call(this,e)}i._configure=function(){n.Buffer&&(i.prototype._slice=n.Buffer.prototype.slice)},i.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},i._configure()},{15:15,9:9}],11:[function(e,t,r){t.exports={}},{}],12:[function(e,t,r){r.Service=e(13)},{13:13}],13:[function(e,t,r){t.exports=n;var o=e(15);function n(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");o.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(n.prototype=Object.create(o.EventEmitter.prototype)).constructor=n,n.prototype.rpcCall=function e(t,r,n,i,s){if(!i)throw TypeError("request must be specified");var a=this;if(!s)return o.asPromise(e,a,t,r,n,i);if(!a.rpcImpl)return setTimeout((function(){s(Error("already ended"))}),0),undefined$1;try{return a.rpcImpl(t,r[a.requestDelimited?"encodeDelimited":"encode"](i).finish(),(function(e,r){if(e)return a.emit("error",e,t),s(e);if(null===r)return a.end(!0),undefined$1;if(!(r instanceof n))try{r=n[a.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",r,t),s(null,r)}))}catch(e){return a.emit("error",e,t),setTimeout((function(){s(e)}),0),undefined$1}},n.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},{15:15}],14:[function(e,t,r){t.exports=n;var o=e(15);function n(e,t){this.lo=e>>>0,this.hi=t>>>0}var i=n.zero=new n(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var s=n.zeroHash="\0\0\0\0\0\0\0\0";n.fromNumber=function(e){if(0===e)return i;var t=e<0;t&&(e=-e);var r=e>>>0,o=(e-r)/4294967296>>>0;return t&&(o=~o>>>0,r=~r>>>0,++r>4294967295&&(r=0,++o>4294967295&&(o=0))),new n(r,o)},n.from=function(e){if("number"==typeof e)return n.fromNumber(e);if(o.isString(e)){if(!o.Long)return n.fromNumber(parseInt(e,10));e=o.Long.fromString(e)}return e.low||e.high?new n(e.low>>>0,e.high>>>0):i},n.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},n.prototype.toLong=function(e){return o.Long?new o.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;n.fromHash=function(e){return e===s?i:new n((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},n.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},n.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},n.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},n.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},{15:15}],15:[function(e,t,r){var o=r;function n(e,t,r){for(var o=Object.keys(t),n=0;n<o.length;++n)e[o[n]]!==undefined$1&&r||(e[o[n]]=t[o[n]]);return e}function i(e){function t(e,r){if(!(this instanceof t))return new t(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),r&&n(this,r)}return(t.prototype=Object.create(Error.prototype)).constructor=t,Object.defineProperty(t.prototype,"name",{get:function(){return e}}),t.prototype.toString=function(){return this.name+": "+this.message},t}o.asPromise=e(1),o.base64=e(2),o.EventEmitter=e(3),o.float=e(4),o.inquire=e(5),o.utf8=e(7),o.pool=e(6),o.LongBits=e(14),o.isNode=Boolean(void 0!==commonjsGlobal&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),o.global=o.isNode&&commonjsGlobal||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,o.emptyArray=Object.freeze?Object.freeze([]):[],o.emptyObject=Object.freeze?Object.freeze({}):{},o.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},o.isString=function(e){return"string"==typeof e||e instanceof String},o.isObject=function(e){return e&&"object"==typeof e},o.isset=o.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},o.Buffer=function(){try{var e=o.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),o._Buffer_from=null,o._Buffer_allocUnsafe=null,o.newBuffer=function(e){return"number"==typeof e?o.Buffer?o._Buffer_allocUnsafe(e):new o.Array(e):o.Buffer?o._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},o.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,o.Long=o.global.dcodeIO&&o.global.dcodeIO.Long||o.global.Long||o.inquire("long"),o.key2Re=/^true|false|0|1$/,o.key32Re=/^-?(?:0|[1-9][0-9]*)$/,o.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,o.longToHash=function(e){return e?o.LongBits.from(e).toHash():o.LongBits.zeroHash},o.longFromHash=function(e,t){var r=o.LongBits.fromHash(e);return o.Long?o.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},o.merge=n,o.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},o.newError=i,o.ProtocolError=i("ProtocolError"),o.oneOfGetter=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&this[e[r]]!==undefined$1&&null!==this[e[r]])return e[r]}},o.oneOfSetter=function(e){return function(t){for(var r=0;r<e.length;++r)e[r]!==t&&delete this[e[r]]}},o.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},o._configure=function(){var e=o.Buffer;e?(o._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,r){return new e(t,r)},o._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):o._Buffer_from=o._Buffer_allocUnsafe=null}},{1:1,14:14,2:2,3:3,4:4,5:5,6:6,7:7}],16:[function(e,t,r){t.exports=m;var o,n=e(15),i=n.LongBits,s=n.base64,a=n.utf8;function u(e,t,r){this.fn=e,this.len=t,this.next=undefined$1,this.val=r}function c(){}function l(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function m(){this.len=0,this.head=new u(c,0,0),this.tail=this.head,this.states=null}var h=function(){return n.Buffer?function(){return(m.create=function(){return new o})()}:function(){return new m}};function d(e,t,r){t[r]=255&e}function f(e,t){this.len=e,this.next=undefined$1,this.val=t}function p(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function g(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}m.create=h(),m.alloc=function(e){return new n.Array(e)},n.Array!==Array&&(m.alloc=n.pool(m.alloc,n.Array.prototype.subarray)),m.prototype._push=function(e,t,r){return this.tail=this.tail.next=new u(e,t,r),this.len+=t,this},f.prototype=Object.create(u.prototype),f.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},m.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new f((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},m.prototype.int32=function(e){return e<0?this._push(p,10,i.fromNumber(e)):this.uint32(e)},m.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},m.prototype.uint64=function(e){var t=i.from(e);return this._push(p,t.length(),t)},m.prototype.int64=m.prototype.uint64,m.prototype.sint64=function(e){var t=i.from(e).zzEncode();return this._push(p,t.length(),t)},m.prototype.bool=function(e){return this._push(d,1,e?1:0)},m.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},m.prototype.sfixed32=m.prototype.fixed32,m.prototype.fixed64=function(e){var t=i.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},m.prototype.sfixed64=m.prototype.fixed64,m.prototype.float=function(e){return this._push(n.float.writeFloatLE,4,e)},m.prototype.double=function(e){return this._push(n.float.writeDoubleLE,8,e)};var y=n.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var o=0;o<e.length;++o)t[r+o]=e[o]};m.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(d,1,0);if(n.isString(e)){var r=m.alloc(t=s.length(e));s.decode(e,r,0),e=r}return this.uint32(t)._push(y,t,e)},m.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(d,1,0)},m.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new u(c,0,0),this.len=0,this},m.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new u(c,0,0),this.len=0),this},m.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},m.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},m._configure=function(e){o=e,m.create=h(),o._configure()}},{15:15}],17:[function(e,t,r){t.exports=i;var o=e(16);(i.prototype=Object.create(o.prototype)).constructor=i;var n=e(15);function i(){o.call(this)}function s(e,t,r){e.length<40?n.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}i._configure=function(){i.alloc=n._Buffer_allocUnsafe,i.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&"set"===n.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var o=0;o<e.length;)t[r++]=e[o++]}},i.prototype.bytes=function(e){n.isString(e)&&(e=n._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(i.writeBytesBuffer,t,e),this},i.prototype.string=function(e){var t=n.Buffer.byteLength(e);return this.uint32(t),t&&this._push(s,t,e),this},i._configure()},{15:15,16:16}]},{},[8])})()})(protobuf);var $protobuf=protobuf.exports,$Reader=$protobuf.Reader,$Writer=$protobuf.Writer,$util=$protobuf.util,$root=$protobuf.roots.default||($protobuf.roots.default={}),common,grpc,gobes,game;$root.game=(game={},game.gobes=((gobes={}).grpc=((grpc={}).common=((common={}).dto=function(){var e={};return e.AckMessage=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.rtnCode=0,e.prototype.msg="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=$Writer.create()),null!=e.rtnCode&&Object.hasOwnProperty.call(e,"rtnCode")&&t.uint32(8).int32(e.rtnCode),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&t.uint32(18).string(e.msg),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.AckMessage;e.pos<r;){var n=e.uint32();switch(n>>>3){case 1:o.rtnCode=e.int32();break;case 2:o.msg=e.string();break;default:e.skipType(7&n)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.rtnCode&&e.hasOwnProperty("rtnCode")&&!$util.isInteger(e.rtnCode)?"rtnCode: integer expected":null!=e.msg&&e.hasOwnProperty("msg")&&!$util.isString(e.msg)?"msg: string expected":null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.AckMessage)return e;var t=new $root.game.gobes.grpc.common.dto.AckMessage;return null!=e.rtnCode&&(t.rtnCode=0|e.rtnCode),null!=e.msg&&(t.msg=String(e.msg)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.rtnCode=0,r.msg=""),null!=e.rtnCode&&e.hasOwnProperty("rtnCode")&&(r.rtnCode=e.rtnCode),null!=e.msg&&e.hasOwnProperty("msg")&&(r.msg=e.msg),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.ClientFrame=function(){function e(e){if(this.data=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.currentFrameId=0,e.prototype.data=$util.emptyArray,e.prototype.timestamp=$util.Long?$util.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=$Writer.create()),null!=e.currentFrameId&&Object.hasOwnProperty.call(e,"currentFrameId")&&t.uint32(8).int32(e.currentFrameId),null!=e.data&&e.data.length)for(var r=0;r<e.data.length;++r)t.uint32(18).string(e.data[r]);return null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(24).int64(e.timestamp),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.ClientFrame;e.pos<r;){var n=e.uint32();switch(n>>>3){case 1:o.currentFrameId=e.int32();break;case 2:o.data&&o.data.length||(o.data=[]),o.data.push(e.string());break;case 3:o.timestamp=e.int64();break;default:e.skipType(7&n)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.currentFrameId&&e.hasOwnProperty("currentFrameId")&&!$util.isInteger(e.currentFrameId))return"currentFrameId: integer expected";if(null!=e.data&&e.hasOwnProperty("data")){if(!Array.isArray(e.data))return"data: array expected";for(var t=0;t<e.data.length;++t)if(!$util.isString(e.data[t]))return"data: string[] expected"}return null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!($util.isInteger(e.timestamp)||e.timestamp&&$util.isInteger(e.timestamp.low)&&$util.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.ClientFrame)return e;var t=new $root.game.gobes.grpc.common.dto.ClientFrame;if(null!=e.currentFrameId&&(t.currentFrameId=0|e.currentFrameId),e.data){if(!Array.isArray(e.data))throw TypeError(".game.gobes.grpc.common.dto.ClientFrame.data: array expected");t.data=[];for(var r=0;r<e.data.length;++r)t.data[r]=String(e.data[r])}return null!=e.timestamp&&($util.Long?(t.timestamp=$util.Long.fromValue(e.timestamp)).unsigned=!1:"string"==typeof e.timestamp?t.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?t.timestamp=e.timestamp:"object"==typeof e.timestamp&&(t.timestamp=new $util.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.data=[]),t.defaults)if(r.currentFrameId=0,$util.Long){var o=new $util.Long(0,0,!1);r.timestamp=t.longs===String?o.toString():t.longs===Number?o.toNumber():o}else r.timestamp=t.longs===String?"0":0;if(null!=e.currentFrameId&&e.hasOwnProperty("currentFrameId")&&(r.currentFrameId=e.currentFrameId),e.data&&e.data.length){r.data=[];for(var n=0;n<e.data.length;++n)r.data[n]=e.data[n]}return null!=e.timestamp&&e.hasOwnProperty("timestamp")&&("number"==typeof e.timestamp?r.timestamp=t.longs===String?String(e.timestamp):e.timestamp:r.timestamp=t.longs===String?$util.Long.prototype.toString.call(e.timestamp):t.longs===Number?new $util.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber():e.timestamp),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.ClientMessage=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.code=0,e.prototype.seq="",e.prototype.timestamp=$util.Long?$util.Long.fromBits(0,0,!1):0,e.prototype.msg=$util.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=$Writer.create()),null!=e.code&&Object.hasOwnProperty.call(e,"code")&&t.uint32(8).int32(e.code),null!=e.seq&&Object.hasOwnProperty.call(e,"seq")&&t.uint32(18).string(e.seq),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(24).int64(e.timestamp),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&t.uint32(34).bytes(e.msg),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.ClientMessage;e.pos<r;){var n=e.uint32();switch(n>>>3){case 1:o.code=e.int32();break;case 2:o.seq=e.string();break;case 3:o.timestamp=e.int64();break;case 4:o.msg=e.bytes();break;default:e.skipType(7&n)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.code&&e.hasOwnProperty("code")&&!$util.isInteger(e.code)?"code: integer expected":null!=e.seq&&e.hasOwnProperty("seq")&&!$util.isString(e.seq)?"seq: string expected":null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!($util.isInteger(e.timestamp)||e.timestamp&&$util.isInteger(e.timestamp.low)&&$util.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":null!=e.msg&&e.hasOwnProperty("msg")&&!(e.msg&&"number"==typeof e.msg.length||$util.isString(e.msg))?"msg: buffer expected":null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.ClientMessage)return e;var t=new $root.game.gobes.grpc.common.dto.ClientMessage;return null!=e.code&&(t.code=0|e.code),null!=e.seq&&(t.seq=String(e.seq)),null!=e.timestamp&&($util.Long?(t.timestamp=$util.Long.fromValue(e.timestamp)).unsigned=!1:"string"==typeof e.timestamp?t.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?t.timestamp=e.timestamp:"object"==typeof e.timestamp&&(t.timestamp=new $util.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber())),null!=e.msg&&("string"==typeof e.msg?$util.base64.decode(e.msg,t.msg=$util.newBuffer($util.base64.length(e.msg)),0):e.msg.length&&(t.msg=e.msg)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(r.code=0,r.seq="",$util.Long){var o=new $util.Long(0,0,!1);r.timestamp=t.longs===String?o.toString():t.longs===Number?o.toNumber():o}else r.timestamp=t.longs===String?"0":0;t.bytes===String?r.msg="":(r.msg=[],t.bytes!==Array&&(r.msg=$util.newBuffer(r.msg)))}return null!=e.code&&e.hasOwnProperty("code")&&(r.code=e.code),null!=e.seq&&e.hasOwnProperty("seq")&&(r.seq=e.seq),null!=e.timestamp&&e.hasOwnProperty("timestamp")&&("number"==typeof e.timestamp?r.timestamp=t.longs===String?String(e.timestamp):e.timestamp:r.timestamp=t.longs===String?$util.Long.prototype.toString.call(e.timestamp):t.longs===Number?new $util.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber():e.timestamp),null!=e.msg&&e.hasOwnProperty("msg")&&(r.msg=t.bytes===String?$util.base64.encode(e.msg,0,e.msg.length):t.bytes===Array?Array.prototype.slice.call(e.msg):e.msg),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.FrameExtInfo=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.seed=$util.Long?$util.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=$Writer.create()),null!=e.seed&&Object.hasOwnProperty.call(e,"seed")&&t.uint32(8).int64(e.seed),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.FrameExtInfo;e.pos<r;){var n=e.uint32();n>>>3==1?o.seed=e.int64():e.skipType(7&n)}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.seed&&e.hasOwnProperty("seed")&&!($util.isInteger(e.seed)||e.seed&&$util.isInteger(e.seed.low)&&$util.isInteger(e.seed.high))?"seed: integer|Long expected":null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.FrameExtInfo)return e;var t=new $root.game.gobes.grpc.common.dto.FrameExtInfo;return null!=e.seed&&($util.Long?(t.seed=$util.Long.fromValue(e.seed)).unsigned=!1:"string"==typeof e.seed?t.seed=parseInt(e.seed,10):"number"==typeof e.seed?t.seed=e.seed:"object"==typeof e.seed&&(t.seed=new $util.LongBits(e.seed.low>>>0,e.seed.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults)if($util.Long){var o=new $util.Long(0,0,!1);r.seed=t.longs===String?o.toString():t.longs===Number?o.toNumber():o}else r.seed=t.longs===String?"0":0;return null!=e.seed&&e.hasOwnProperty("seed")&&("number"==typeof e.seed?r.seed=t.longs===String?String(e.seed):e.seed:r.seed=t.longs===String?$util.Long.prototype.toString.call(e.seed):t.longs===Number?new $util.LongBits(e.seed.low>>>0,e.seed.high>>>0).toNumber():e.seed),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.FrameInfo=function(){function e(e){if(this.data=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.playerId="",e.prototype.data=$util.emptyArray,e.prototype.timestamp=$util.Long?$util.Long.fromBits(0,0,!1):0,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=$Writer.create()),null!=e.playerId&&Object.hasOwnProperty.call(e,"playerId")&&t.uint32(10).string(e.playerId),null!=e.data&&e.data.length)for(var r=0;r<e.data.length;++r)t.uint32(18).string(e.data[r]);return null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(24).int64(e.timestamp),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.FrameInfo;e.pos<r;){var n=e.uint32();switch(n>>>3){case 1:o.playerId=e.string();break;case 2:o.data&&o.data.length||(o.data=[]),o.data.push(e.string());break;case 3:o.timestamp=e.int64();break;default:e.skipType(7&n)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.playerId&&e.hasOwnProperty("playerId")&&!$util.isString(e.playerId))return"playerId: string expected";if(null!=e.data&&e.hasOwnProperty("data")){if(!Array.isArray(e.data))return"data: array expected";for(var t=0;t<e.data.length;++t)if(!$util.isString(e.data[t]))return"data: string[] expected"}return null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!($util.isInteger(e.timestamp)||e.timestamp&&$util.isInteger(e.timestamp.low)&&$util.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.FrameInfo)return e;var t=new $root.game.gobes.grpc.common.dto.FrameInfo;if(null!=e.playerId&&(t.playerId=String(e.playerId)),e.data){if(!Array.isArray(e.data))throw TypeError(".game.gobes.grpc.common.dto.FrameInfo.data: array expected");t.data=[];for(var r=0;r<e.data.length;++r)t.data[r]=String(e.data[r])}return null!=e.timestamp&&($util.Long?(t.timestamp=$util.Long.fromValue(e.timestamp)).unsigned=!1:"string"==typeof e.timestamp?t.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?t.timestamp=e.timestamp:"object"==typeof e.timestamp&&(t.timestamp=new $util.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.data=[]),t.defaults)if(r.playerId="",$util.Long){var o=new $util.Long(0,0,!1);r.timestamp=t.longs===String?o.toString():t.longs===Number?o.toNumber():o}else r.timestamp=t.longs===String?"0":0;if(null!=e.playerId&&e.hasOwnProperty("playerId")&&(r.playerId=e.playerId),e.data&&e.data.length){r.data=[];for(var n=0;n<e.data.length;++n)r.data[n]=e.data[n]}return null!=e.timestamp&&e.hasOwnProperty("timestamp")&&("number"==typeof e.timestamp?r.timestamp=t.longs===String?String(e.timestamp):e.timestamp:r.timestamp=t.longs===String?$util.Long.prototype.toString.call(e.timestamp):t.longs===Number?new $util.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber():e.timestamp),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.PlayerInfo=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.playerId="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=$Writer.create()),null!=e.playerId&&Object.hasOwnProperty.call(e,"playerId")&&t.uint32(10).string(e.playerId),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.PlayerInfo;e.pos<r;){var n=e.uint32();n>>>3==1?o.playerId=e.string():e.skipType(7&n)}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.playerId&&e.hasOwnProperty("playerId")&&!$util.isString(e.playerId)?"playerId: string expected":null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.PlayerInfo)return e;var t=new $root.game.gobes.grpc.common.dto.PlayerInfo;return null!=e.playerId&&(t.playerId=String(e.playerId)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.playerId=""),null!=e.playerId&&e.hasOwnProperty("playerId")&&(r.playerId=e.playerId),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.QueryFrameResult=function(){function e(e){if(this.relayFrameInfos=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.relayFrameInfos=$util.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=$Writer.create()),null!=e.relayFrameInfos&&e.relayFrameInfos.length)for(var r=0;r<e.relayFrameInfos.length;++r)$root.game.gobes.grpc.common.dto.RelayFrameInfo.encode(e.relayFrameInfos[r],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.QueryFrameResult;e.pos<r;){var n=e.uint32();n>>>3==1?(o.relayFrameInfos&&o.relayFrameInfos.length||(o.relayFrameInfos=[]),o.relayFrameInfos.push($root.game.gobes.grpc.common.dto.RelayFrameInfo.decode(e,e.uint32()))):e.skipType(7&n)}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.relayFrameInfos&&e.hasOwnProperty("relayFrameInfos")){if(!Array.isArray(e.relayFrameInfos))return"relayFrameInfos: array expected";for(var t=0;t<e.relayFrameInfos.length;++t){var r=$root.game.gobes.grpc.common.dto.RelayFrameInfo.verify(e.relayFrameInfos[t]);if(r)return"relayFrameInfos."+r}}return null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.QueryFrameResult)return e;var t=new $root.game.gobes.grpc.common.dto.QueryFrameResult;if(e.relayFrameInfos){if(!Array.isArray(e.relayFrameInfos))throw TypeError(".game.gobes.grpc.common.dto.QueryFrameResult.relayFrameInfos: array expected");t.relayFrameInfos=[];for(var r=0;r<e.relayFrameInfos.length;++r){if("object"!=typeof e.relayFrameInfos[r])throw TypeError(".game.gobes.grpc.common.dto.QueryFrameResult.relayFrameInfos: object expected");t.relayFrameInfos[r]=$root.game.gobes.grpc.common.dto.RelayFrameInfo.fromObject(e.relayFrameInfos[r])}}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.relayFrameInfos=[]),e.relayFrameInfos&&e.relayFrameInfos.length){r.relayFrameInfos=[];for(var o=0;o<e.relayFrameInfos.length;++o)r.relayFrameInfos[o]=$root.game.gobes.grpc.common.dto.RelayFrameInfo.toObject(e.relayFrameInfos[o],t)}return r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.QueryFrame=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.currentFrameId=0,e.prototype.size=0,e.prototype.mode=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=$Writer.create()),null!=e.currentFrameId&&Object.hasOwnProperty.call(e,"currentFrameId")&&t.uint32(8).int32(e.currentFrameId),null!=e.size&&Object.hasOwnProperty.call(e,"size")&&t.uint32(16).int32(e.size),null!=e.mode&&Object.hasOwnProperty.call(e,"mode")&&t.uint32(24).int32(e.mode),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.QueryFrame;e.pos<r;){var n=e.uint32();switch(n>>>3){case 1:o.currentFrameId=e.int32();break;case 2:o.size=e.int32();break;case 3:o.mode=e.int32();break;default:e.skipType(7&n)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.currentFrameId&&e.hasOwnProperty("currentFrameId")&&!$util.isInteger(e.currentFrameId)?"currentFrameId: integer expected":null!=e.size&&e.hasOwnProperty("size")&&!$util.isInteger(e.size)?"size: integer expected":null!=e.mode&&e.hasOwnProperty("mode")&&!$util.isInteger(e.mode)?"mode: integer expected":null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.QueryFrame)return e;var t=new $root.game.gobes.grpc.common.dto.QueryFrame;return null!=e.currentFrameId&&(t.currentFrameId=0|e.currentFrameId),null!=e.size&&(t.size=0|e.size),null!=e.mode&&(t.mode=0|e.mode),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.currentFrameId=0,r.size=0,r.mode=0),null!=e.currentFrameId&&e.hasOwnProperty("currentFrameId")&&(r.currentFrameId=e.currentFrameId),null!=e.size&&e.hasOwnProperty("size")&&(r.size=e.size),null!=e.mode&&e.hasOwnProperty("mode")&&(r.mode=e.mode),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.RelayFrameInfo=function(){function e(e){if(this.frameInfo=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.currentRoomFrameId=0,e.prototype.frameInfo=$util.emptyArray,e.prototype.ext=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=$Writer.create()),null!=e.currentRoomFrameId&&Object.hasOwnProperty.call(e,"currentRoomFrameId")&&t.uint32(8).int32(e.currentRoomFrameId),null!=e.frameInfo&&e.frameInfo.length)for(var r=0;r<e.frameInfo.length;++r)$root.game.gobes.grpc.common.dto.FrameInfo.encode(e.frameInfo[r],t.uint32(18).fork()).ldelim();return null!=e.ext&&Object.hasOwnProperty.call(e,"ext")&&$root.game.gobes.grpc.common.dto.FrameExtInfo.encode(e.ext,t.uint32(26).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.RelayFrameInfo;e.pos<r;){var n=e.uint32();switch(n>>>3){case 1:o.currentRoomFrameId=e.int32();break;case 2:o.frameInfo&&o.frameInfo.length||(o.frameInfo=[]),o.frameInfo.push($root.game.gobes.grpc.common.dto.FrameInfo.decode(e,e.uint32()));break;case 3:o.ext=$root.game.gobes.grpc.common.dto.FrameExtInfo.decode(e,e.uint32());break;default:e.skipType(7&n)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.currentRoomFrameId&&e.hasOwnProperty("currentRoomFrameId")&&!$util.isInteger(e.currentRoomFrameId))return"currentRoomFrameId: integer expected";if(null!=e.frameInfo&&e.hasOwnProperty("frameInfo")){if(!Array.isArray(e.frameInfo))return"frameInfo: array expected";for(var t=0;t<e.frameInfo.length;++t)if(r=$root.game.gobes.grpc.common.dto.FrameInfo.verify(e.frameInfo[t]))return"frameInfo."+r}var r;return null!=e.ext&&e.hasOwnProperty("ext")&&(r=$root.game.gobes.grpc.common.dto.FrameExtInfo.verify(e.ext))?"ext."+r:null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.RelayFrameInfo)return e;var t=new $root.game.gobes.grpc.common.dto.RelayFrameInfo;if(null!=e.currentRoomFrameId&&(t.currentRoomFrameId=0|e.currentRoomFrameId),e.frameInfo){if(!Array.isArray(e.frameInfo))throw TypeError(".game.gobes.grpc.common.dto.RelayFrameInfo.frameInfo: array expected");t.frameInfo=[];for(var r=0;r<e.frameInfo.length;++r){if("object"!=typeof e.frameInfo[r])throw TypeError(".game.gobes.grpc.common.dto.RelayFrameInfo.frameInfo: object expected");t.frameInfo[r]=$root.game.gobes.grpc.common.dto.FrameInfo.fromObject(e.frameInfo[r])}}if(null!=e.ext){if("object"!=typeof e.ext)throw TypeError(".game.gobes.grpc.common.dto.RelayFrameInfo.ext: object expected");t.ext=$root.game.gobes.grpc.common.dto.FrameExtInfo.fromObject(e.ext)}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.frameInfo=[]),t.defaults&&(r.currentRoomFrameId=0,r.ext=null),null!=e.currentRoomFrameId&&e.hasOwnProperty("currentRoomFrameId")&&(r.currentRoomFrameId=e.currentRoomFrameId),e.frameInfo&&e.frameInfo.length){r.frameInfo=[];for(var o=0;o<e.frameInfo.length;++o)r.frameInfo[o]=$root.game.gobes.grpc.common.dto.FrameInfo.toObject(e.frameInfo[o],t)}return null!=e.ext&&e.hasOwnProperty("ext")&&(r.ext=$root.game.gobes.grpc.common.dto.FrameExtInfo.toObject(e.ext,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.ServerMessage=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.code=0,e.prototype.seq="",e.prototype.timestamp=$util.Long?$util.Long.fromBits(0,0,!1):0,e.prototype.msg=$util.newBuffer([]),e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=$Writer.create()),null!=e.code&&Object.hasOwnProperty.call(e,"code")&&t.uint32(8).int32(e.code),null!=e.seq&&Object.hasOwnProperty.call(e,"seq")&&t.uint32(18).string(e.seq),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(24).int64(e.timestamp),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&t.uint32(34).bytes(e.msg),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof $Reader||(e=$Reader.create(e));for(var r=void 0===t?e.len:e.pos+t,o=new $root.game.gobes.grpc.common.dto.ServerMessage;e.pos<r;){var n=e.uint32();switch(n>>>3){case 1:o.code=e.int32();break;case 2:o.seq=e.string();break;case 3:o.timestamp=e.int64();break;case 4:o.msg=e.bytes();break;default:e.skipType(7&n)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.code&&e.hasOwnProperty("code")&&!$util.isInteger(e.code)?"code: integer expected":null!=e.seq&&e.hasOwnProperty("seq")&&!$util.isString(e.seq)?"seq: string expected":null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!($util.isInteger(e.timestamp)||e.timestamp&&$util.isInteger(e.timestamp.low)&&$util.isInteger(e.timestamp.high))?"timestamp: integer|Long expected":null!=e.msg&&e.hasOwnProperty("msg")&&!(e.msg&&"number"==typeof e.msg.length||$util.isString(e.msg))?"msg: buffer expected":null},e.fromObject=function(e){if(e instanceof $root.game.gobes.grpc.common.dto.ServerMessage)return e;var t=new $root.game.gobes.grpc.common.dto.ServerMessage;return null!=e.code&&(t.code=0|e.code),null!=e.seq&&(t.seq=String(e.seq)),null!=e.timestamp&&($util.Long?(t.timestamp=$util.Long.fromValue(e.timestamp)).unsigned=!1:"string"==typeof e.timestamp?t.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?t.timestamp=e.timestamp:"object"==typeof e.timestamp&&(t.timestamp=new $util.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber())),null!=e.msg&&("string"==typeof e.msg?$util.base64.decode(e.msg,t.msg=$util.newBuffer($util.base64.length(e.msg)),0):e.msg.length&&(t.msg=e.msg)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(r.code=0,r.seq="",$util.Long){var o=new $util.Long(0,0,!1);r.timestamp=t.longs===String?o.toString():t.longs===Number?o.toNumber():o}else r.timestamp=t.longs===String?"0":0;t.bytes===String?r.msg="":(r.msg=[],t.bytes!==Array&&(r.msg=$util.newBuffer(r.msg)))}return null!=e.code&&e.hasOwnProperty("code")&&(r.code=e.code),null!=e.seq&&e.hasOwnProperty("seq")&&(r.seq=e.seq),null!=e.timestamp&&e.hasOwnProperty("timestamp")&&("number"==typeof e.timestamp?r.timestamp=t.longs===String?String(e.timestamp):e.timestamp:r.timestamp=t.longs===String?$util.Long.prototype.toString.call(e.timestamp):t.longs===Number?new $util.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber():e.timestamp),null!=e.msg&&e.hasOwnProperty("msg")&&(r.msg=t.bytes===String?$util.base64.encode(e.msg,0,e.msg.length):t.bytes===Array?Array.prototype.slice.call(e.msg):e.msg),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e}(),common),grpc),gobes),game);var compiled=$root;const{dto:dto}=compiled.game.gobes.grpc.common;class Logger{static log(e){console.log("[GOBE LOG]:",Object.assign({timestamp:Date.now()},e))}static warn(e){console.warn("[GOBE WARN]:",Object.assign({timestamp:Date.now()},e))}static error(e){console.error("[GOBE ERROR]:",Object.assign({timestamp:Date.now()},e))}}const{ServerMessage:ServerMessage,ClientMessage:ClientMessage,AckMessage:AckMessage,ClientFrame:ClientFrame,QueryFrame:QueryFrame,RelayFrameInfo:RelayFrameInfo,QueryFrameResult:QueryFrameResult}=dto,PlayerFrameInfo=dto.PlayerInfo;class Room extends Base{constructor(e,t){super(),this.onJoin=createSignal(),this.onLeave=createSignal(),this.onDismiss=createSignal(),this.onDisconnect=createSignal(),this.onStartFrameSync=createSignal(),this.onStopFrameSync=createSignal(),this.onRecvFrame=createSignal(),this.onRequestFrameError=createSignal(),this.connection=null,this.frameId=0,this.frameRequestMaxSize=1e3,this.frameRequesting=!1,this.frameRequestSize=0,this.frameRequestList=[],this.autoFrameRequesting=!1,this.autoFrameRequestCacheList=[],this.endpoint="",this._isSyncing=!1,this.config=t,this._isSyncing=1==t.roomStatus,this._client=e,this._player=new Player}get id(){return this.config.roomId}get roomType(){return this.config.roomType}get roomName(){return this.config.roomName}get roomCode(){return this.config.roomCode}get customRoomProperties(){return this.config.customRoomProperties}get ownerId(){return this.config.ownerId}get maxPlayers(){return this.config.maxPlayers}get players(){return this.config.players}get router(){return this.config.router}get isPrivate(){return this.config.isPrivate}get createTime(){return this.config.createTime}get player(){return this._player}get isSyncing(){return this._isSyncing}connect(e,t){this.connection=new Connection,this.connection.events.onmessage=this.onMessageCallback.bind(this),this.connection.events.onclose=e=>{5!=this.state&&(this.onDisconnect.emit({playerId:this.playerId},e),Logger.warn({eventType:"WebSocket Close",event:e})),this.setState(1),this.setRoomId(""),this.stopWSHeartbeat()},this.endpoint=this.buildEndpoint(e,t),this.connection.connect(this.endpoint)}sendFrame(e){var t;this.checkInSync();const r=ClientFrame.create({currentFrameId:this.frameId,timestamp:Date.now(),data:"string"==typeof e?[e]:e}),o=ClientMessage.create({timestamp:Date.now(),seq:this.sendFrame.name,code:4,msg:ClientFrame.encode(r).finish()});null===(t=this.connection)||void 0===t||t.send(ClientMessage.encode(o).finish())}requestFrame(e,t){var r;this.checkInSync(),this.checkNotInRequesting(),this.frameRequesting=!0,this.frameRequestSize=t;const o=Math.ceil(t/this.frameRequestMaxSize);let n=0;for(;n<o;){const o=e+this.frameRequestMaxSize*n,i=QueryFrame.create({mode:1,currentFrameId:o,size:Math.min(this.frameRequestMaxSize,t-n*this.frameRequestMaxSize)}),s=ClientMessage.create({timestamp:Date.now(),seq:this.requestFrame.name,code:6,msg:QueryFrame.encode(i).finish()});null===(r=this.connection)||void 0===r||r.send(ClientMessage.encode(s).finish()),n+=1}}removeAllListeners(){[this.onJoin,this.onLeave,this.onDismiss,this.onDisconnect,this.onStartFrameSync,this.onStopFrameSync,this.onRecvFrame].forEach((e=>e.clear()))}reconnect(){return __awaiter(this,void 0,void 0,(function*(){if(yield this._client.init(),!this.lastRoomId)throw new GOBEError(90002);const{roomInfo:e,ticket:t}=yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.room.join",roomId:this.config.roomId,customPlayerStatus:this._player.customStatus,customPlayerProperties:this._player.customProperties}));this.setState(4),this.setRoomId(e.roomId),yield heartbeat.send(4),this.connect(e.router.routerAddr,t)}))}startFrameSync(){return __awaiter(this,void 0,void 0,(function*(){this.checkNotInSync(),yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.frame.sync.begin",roomId:this.id}),yield heartbeat.send(6)}))}stopFrameSync(){return __awaiter(this,void 0,void 0,(function*(){this.checkInSync(),yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.frame.sync.stop",roomId:this.id}),yield heartbeat.send(7)}))}update(){return __awaiter(this,void 0,void 0,(function*(){const{roomInfo:e}=yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.room.detail",roomId:this.id});return Object.assign(this.config,e),this}))}leave(){return __awaiter(this,void 0,void 0,(function*(){yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.room.leave",roomId:this.id}),yield heartbeat.send(5),this.setState(5)}))}dismiss(){return __awaiter(this,void 0,void 0,(function*(){yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.room.dismiss",roomId:this.id}),yield heartbeat.send(5),this.setState(5)}))}removePlayer(e){return __awaiter(this,void 0,void 0,(function*(){this.checkNotInSync(),yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.room.remove",roomId:this.id,playerId:e})}))}onMessageCallback(e){return __awaiter(this,void 0,void 0,(function*(){const t=ServerMessage.decode(new Uint8Array(e.data)),{code:r}=t.toJSON(),{msg:o}=t;switch(r){case 1:this.clearRequestFrame(),this.startWSHeartbeat(),this.setState(2),this.setRoomId(this.id),this.onJoin.emit({playerId:this.playerId});break;case 8:this.setState(3),this.frameId=0,this._isSyncing=!0,this.onStartFrameSync.emit();break;case 10:{const e=RelayFrameInfo.decode(o).toJSON();this.autoFrameRequesting?this.autoFrameRequestCacheList.push(e):e.currentRoomFrameId-this.frameId>1?(this.autoFrameRequesting=!0,this.autoFrameRequestCacheList.push(e),this.requestFrame(this.frameId+1,e.currentRoomFrameId-this.frameId-1)):(this.frameId=e.currentRoomFrameId,this.onRecvFrame.emit(e));break}case 9:this.setState(2),this._isSyncing=!1,this.onStopFrameSync.emit();break;case 7:{const e=AckMessage.decode(o).toJSON();e.rtnCode&&0!=e.rtnCode&&(this.clearRequestFrame(),this.onRequestFrameError.emit(new GOBEError(e.rtnCode,e.msg)));break}case 17:{const e=QueryFrameResult.decode(o).toJSON().relayFrameInfos;if(this.frameRequestList.push(...e),this.frameRequestList.length==this.frameRequestSize){const e=this.autoFrameRequestCacheList,t=this.frameRequestList;t.sort(((e,t)=>e.currentRoomFrameId-t.currentRoomFrameId)),this.autoFrameRequesting?(this.clearRequestFrame(),this.frameId=e[e.length-1].currentRoomFrameId,this.onRecvFrame.emit([...t,...e])):(this.clearRequestFrame(),this.onRecvFrame.emit(t))}break}case 12:{const e=PlayerFrameInfo.decode(o).toJSON();this.onJoin.emit(e);break}case 13:{const e=PlayerFrameInfo.decode(o).toJSON();this.onLeave.emit(e);break}case 15:{const e=PlayerFrameInfo.decode(o).toJSON();this.onDisconnect.emit(e);break}case 16:yield heartbeat.send(5),this.setState(5),this.onDismiss.emit()}}))}clearRequestFrame(){this.frameRequesting=!1,this.frameRequestSize=0,this.frameRequestList=[],this.autoFrameRequesting=!1,this.autoFrameRequestCacheList=[]}startWSHeartbeat(){this.wsHeartbeatTimer=setInterval((()=>this.doWSHeartbeat()),5e3)}doWSHeartbeat(){var e;const t=ClientMessage.create({code:2,seq:this.doWSHeartbeat.name,timestamp:Date.now()});null===(e=this.connection)||void 0===e||e.send(ClientMessage.encode(t).finish())}stopWSHeartbeat(){this.wsHeartbeatTimer&&clearInterval(this.wsHeartbeatTimer)}buildEndpoint(e,t){return`wss://${e}/hw-game-obe/endpoint?sdkVersion=10105200&ticket=${t}`}checkInSync(){if(!this._isSyncing)throw new GOBEError(90005);return!0}checkNotInSync(){if(this._isSyncing)throw new GOBEError(90006);return!0}checkNotInRequesting(){if(this.frameRequesting)throw new GOBEError(90010);return!0}}class Group extends Base{constructor(e,t){super(),this.onJoin=createSignal(),this.onLeave=createSignal(),this.onDismiss=createSignal(),this.onUpdate=createSignal(),this.onMatchStart=createSignal(),this.config=t,this._client=e,this._player=new Player}get id(){return this.config.groupId}get groupName(){return this.config.groupName}get maxPlayers(){return this.config.maxPlayers}get ownerId(){return this.config.ownerId}get customGroupProperties(){return this.config.customGroupProperties}get isLock(){return this.config.isLock}get isPersistent(){return this.config.isPersistent}get players(){return this.config.players}get player(){return this._player}query(){return __awaiter(this,void 0,void 0,(function*(){const{groupInfo:e}=yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.group.detail",groupId:this.id});return Object.assign(this.config,e),this}))}leave(){return __awaiter(this,void 0,void 0,(function*(){yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.group.leave",groupId:this.id})}))}dismiss(){return __awaiter(this,void 0,void 0,(function*(){yield Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.group.dismiss",groupId:this.id})}))}updateGroup(e){return __awaiter(this,void 0,void 0,(function*(){this.checkUpdatePermission(),yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.group.change",groupId:this.id},e))}))}checkUpdatePermission(){if(this.playerId!=this.ownerId)throw new GOBEError(80003,"You are no permission to update!");return!0}onServerEventChange(e){return __awaiter(this,void 0,void 0,(function*(){switch(e.eventType){case 1:this.onMatchStart.emit(e);break;case 6:this.onJoin.emit(e);break;case 7:this.onLeave.emit(e);break;case 8:this._client.removeGroup(),this.onDismiss.emit(e);break;case 9:this.onUpdate.emit(e)}}))}removeAllListeners(){[this.onJoin,this.onLeave,this.onDismiss,this.onUpdate,this.onMatchStart].forEach((e=>e.clear()))}}class Client extends Base{constructor(e){super(),this._room=null,this._group=null,this._pollInterval=2e3,this._isMatching=!1,this._isCancelMatch=!1,this._loginTimestamp=0,this.setAppId(e.appId),this.setOpenId(e.openId),this._auth=new Auth(e.clientId,e.clientSecret,e.createSignature)}get room(){return this._room}get group(){return this._group}get loginTimestamp(){return this._loginTimestamp}init(){return __awaiter(this,void 0,void 0,(function*(){const{gameInfo:e,timeStamp:t}=yield this._auth.login();return this._loginTimestamp=t,e.httpTimeout&&(Request.timeout=e.httpTimeout),e.pollInterval&&(this._pollInterval=e.pollInterval),this}))}createRoom(e,t){return __awaiter(this,void 0,void 0,(function*(){this.checkCreateRoomConfig(e),this.checkInit(),this.checkCreateOrJoin();const{roomInfo:r,ticket:o}=yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.room.create",isPrivate:0},e,t));return this.setState(4),this.setRoomId(r.roomId),yield heartbeat.send(4),this._room=new Room(this,r),this._room.player.customStatus=null==t?void 0:t.customPlayerStatus,this._room.player.customProperties=null==t?void 0:t.customPlayerProperties,this._room.connect(r.router.routerAddr,o),this._room}))}createGroup(e,t){return __awaiter(this,void 0,void 0,(function*(){this.checkCreateGroupConfig(e),this.checkInit(),this.checkGroupCreateOrJoin();const{groupInfo:r}=yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign(Object.assign({method:"client.gobe.group.create"},e),t));return this.setGroupId(r.groupId),this._group=new Group(this,r),this._group.player.customStatus=null==t?void 0:t.customPlayerStatus,this._group.player.customProperties=null==t?void 0:t.customPlayerProperties,this._group}))}joinRoom(e,t){return __awaiter(this,void 0,void 0,(function*(){this.checkInit(),this.checkCreateOrJoin();const r=this.checkJoinRoomConfig(e),{roomInfo:o,ticket:n}=yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign(Object.assign({method:"client.gobe.room.join"},r),t));return this.setState(4),this.setRoomId(o.roomId),yield heartbeat.send(4),this._room=new Room(this,o),this._room.player.customStatus=null==t?void 0:t.customPlayerStatus,this._room.player.customProperties=null==t?void 0:t.customPlayerProperties,this._room.connect(o.router.routerAddr,n),this._room}))}joinGroup(e,t){return __awaiter(this,void 0,void 0,(function*(){this.checkInit(),this.checkGroupCreateOrJoin();const{groupInfo:r}=yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.group.join",groupId:e},t));return this.setGroupId(r.groupId),this._group=new Group(this,r),this._group.player.customStatus=null==t?void 0:t.customPlayerStatus,this._group.player.customProperties=null==t?void 0:t.customPlayerProperties,this._group}))}leaveRoom(){var e;return __awaiter(this,void 0,void 0,(function*(){return this.checkInit(),this.checkLeaveOrdismiss(),yield null===(e=this._room)||void 0===e?void 0:e.leave(),this}))}dismissRoom(){var e;return __awaiter(this,void 0,void 0,(function*(){return this.checkInit(),this.checkLeaveOrdismiss(),yield null===(e=this._room)||void 0===e?void 0:e.dismiss(),this}))}leaveGroup(){var e;return __awaiter(this,void 0,void 0,(function*(){return this.checkInit(),this.checkGroupLeaveOrdismiss(),yield null===(e=this._group)||void 0===e?void 0:e.leave(),this._group=null,this}))}dismissGroup(){var e;return __awaiter(this,void 0,void 0,(function*(){return this.checkInit(),this.checkGroupLeaveOrdismiss(),yield null===(e=this._group)||void 0===e?void 0:e.dismiss(),this._group=null,this}))}removeGroup(){this._group=null}getAvailableRooms(e){return __awaiter(this,void 0,void 0,(function*(){this.checkInit();const{rooms:t,count:r,offset:o,hasNext:n}=yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.room.list.query"},e));return{rooms:t,count:r,offset:o,hasNext:n}}))}matchRoom(e,t){return __awaiter(this,void 0,void 0,(function*(){this.checkInit(),this.checkCreateOrJoin();const r=this._pollInterval,o=Date.now();const n=yield function t(){return new Promise(((n,i)=>{Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.room.match"},e)).then((e=>n(e.roomId))).catch((e=>{104102==(null==e?void 0:e.code)?setTimeout((()=>{n(t())}),r):Date.now()-o>=3e5?i(new GOBEError(104103)):i(e)}))}))}();return this.joinRoom(n,t)}))}matchPlayer(e,t){return __awaiter(this,void 0,void 0,(function*(){this.checkInit(),this.checkCreateOrJoin();const r=yield this.matchPolling((()=>Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.online.match"},e))));return this.joinRoom(r,t)}))}matchGroup(e,t){var r;return __awaiter(this,void 0,void 0,(function*(){if(this.checkInit(),this.checkCreateOrJoin(),this.checkMatching(),(null===(r=this._group)||void 0===r?void 0:r.ownerId)==this.playerId){const t=yield Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.group.change",groupId:this.groupId,isLock:1})),{players:r}=t.groupInfo;if(r.length!=e.playerInfos.length)throw new GOBEError(90011);const o=r.map((e=>e.playerId)),n=new Set(o);for(const{playerId:t}of e.playerInfos)if(!n.has(t))throw new GOBEError(90011)}const o=yield this.matchPolling((()=>Request.post("/gamex-edge-service/v1/gameXClientApi",Object.assign({method:"client.gobe.group.match"},e))));return this.joinRoom(o,t)}))}cancelMatch(){this.checkInit(),this._isCancelMatch=!0}requestCancelMatch(){return new Promise(((e,t)=>{Request.post("/gamex-edge-service/v1/gameXClientApi",{method:"client.gobe.match.cancel"},void 0,!1).then((r=>{0===r.rtnCode?e(r):t(r)}))}))}matchPolling(e){return this._isMatching=!0,new Promise(((t,r)=>{this._isCancelMatch?this.requestCancelMatch().then((()=>{this._isMatching=!1,r(new GOBEError(104205))})).catch((o=>{104206===o.rtnCode&&o.roomId?(this._isMatching=!1,t(o.roomId)):104204===o.rtnCode?setTimeout((()=>{t(this.matchPolling(e))}),this._pollInterval):(this._isMatching=!1,r(o))})).finally((()=>{this._isCancelMatch=!1})):e().then((e=>{this._isMatching=!1,t(e.roomId)})).catch((o=>{104202===o.code?setTimeout((()=>{t(this.matchPolling(e))}),this._pollInterval):(this._isMatching=!1,r(o))}))}))}onStateChange(e,t){1==e&&0!=t&&(this._room=null)}checkInit(){if(0==this.state)throw new GOBEError(90001);return!0}checkCreateOrJoin(){if(this._room&&1!=this.state)throw new GOBEError(90003);return!0}checkGroupCreateOrJoin(){if(this._group&&1==this.state)throw new GOBEError(80004);return!0}checkLeaveOrdismiss(){if(!this._room&&1==this.state)throw new GOBEError(90002);return!0}checkGroupLeaveOrdismiss(){if(!this._group&&1==this.state)throw new GOBEError(80001);return!0}checkCreateRoomConfig(e){var t;if(((null===(t=e.roomName)||void 0===t?void 0:t.length)||0)>64)throw new GOBEError(10001);return!0}checkCreateGroupConfig(e){var t;if(((null===(t=e.groupName)||void 0===t?void 0:t.length)||0)>64)throw new GOBEError(80002);return!0}checkJoinRoomConfig(e){const t={roomId:"",roomCode:""};switch(e.length){case 6:t.roomCode=e;break;case 18:t.roomId=e;break;default:throw new GOBEError(90007)}return t}checkMatching(){if(this._isMatching)throw new GOBEError(90008);return!0}}class Random{constructor(e){if(this.mask=123459876,this.m=2147483647,this.a=16807,"number"!=typeof e||e!=e||e%1!=0||e<1)throw new TypeError("Seed must be a positive integer.");this.seed=e%1e8}getNumber(){this.seed=this.seed^this.mask,this.seed=this.a*this.seed%this.m;const e=this.seed/this.m;return this.seed=this.seed^this.mask,e}}heartbeat.schedule(),exports.Base=Base,exports.Client=Client,exports.EventEmitter=EventEmitter,exports.GOBEError=GOBEError,exports.Group=Group,exports.Player=Player,exports.RandomUtils=Random,exports.Room=Room,Object.defineProperty(exports,"__esModule",{value:!0})}));
{
"type": "software",
"scope": "game",
"name": "GameOBESDK",
"version": "1.1.5.300",
"playbook": ""
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "0614d8cf-dd45-41f8-87d4-bee49ddea0f3",
"subMetas": {}
}
\ No newline at end of file
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "821c2d0d-9578-4d1c-9d43-1432e2e9a23c", "uuid": "7ad93cad-25ac-4bb2-9957-8a31330f3a09",
"isBundle": false, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
......
export as namespace Play;
declare class EventEmitter<T> {
on<K extends keyof T>(event: K, listener: (payload: T[K]) => any): this;
on(evt: string, listener: Function): this;
once<K extends keyof T>(event: K, listener: (payload: T[K]) => any): this;
once(evt: string, listener: Function): this;
off<K extends keyof T>(evt: K | string, listener?: Function): this;
emit<K extends keyof T>(evt: K | string, ...args: any[]): boolean;
}
export enum Event {
/** 断开连接 */
DISCONNECTED = 'disconnected',
/** 加入到大厅 */
LOBBY_JOINED = 'lobbyJoined',
/** 大厅房间列表变化 */
LOBBY_ROOM_LIST_UPDATED = 'lobbyRoomListUpdate',
/** 有新玩家加入房间 */
PLAYER_ROOM_JOINED = 'newPlayerJoinedRoom',
/** 有玩家离开房间 */
PLAYER_ROOM_LEFT = 'playerLeftRoom',
/** 玩家活跃属性变化 */
PLAYER_ACTIVITY_CHANGED = 'playerActivityChanged',
/** 主机变更 */
MASTER_SWITCHED = 'masterSwitched',
/** 离开房间 */
ROOM_LEFT = 'roomLeft',
/** 被踢出房间 */
ROOM_KICKED = 'roomKicked',
/** 房间系统属性变化 */
ROOM_SYSTEM_PROPERTIES_CHANGED = 'roomSystemPropertiesChanged',
/** 房间自定义属性变化 */
ROOM_CUSTOM_PROPERTIES_CHANGED = 'roomCustomPropertiesChanged',
/** 玩家自定义属性变化 */
PLAYER_CUSTOM_PROPERTIES_CHANGED = 'playerCustomPropertiesChanged',
/** 自定义事件 */
CUSTOM_EVENT = 'customEvent',
/** 错误事件 */
ERROR = 'error',
}
export enum ReceiverGroup {
/** 其他人(除了自己之外的所有人) */
Others,
/** 所有人(包括自己) */
All,
/** 主机客户端 */
MasterClient,
}
interface CustomProperties {
[key: string]: any;
}
interface CustomEventData {
[key: string]: any;
}
interface ErrorEvent {
code: number;
detail: string;
}
declare interface PlayEvent {
connected: void;
connectFailed: ErrorEvent;
disconnected: void;
lobbyJoined: void;
lobbyLeft: void;
lobbyRoomListUpdate: void;
roomCreated: void;
roomCreateFailed: ErrorEvent;
roomJoined: void;
roomJoinFailed: ErrorEvent;
newPlayerJoinedRoom: {
newPlayer: Player;
};
playerLeftRoom: {
leftPlayer: Player;
};
playerActivityChanged: {
player: Player;
};
masterSwitched: {
newMaster: Player;
};
roomLeft: void;
roomKicked: {
code: number;
msg: string;
};
roomCustomPropertiesChanged: {
changedProps: CustomProperties;
};
roomSystemPropertiesChanged: {
changedProps: CustomProperties;
};
playerCustomPropertiesChanged: {
player: Player;
changedProps: CustomProperties;
};
customEvent: {
eventId: number;
eventData: CustomEventData;
senderId: number;
};
error: ErrorEvent;
}
export class LobbyRoom {
readonly roomName: string;
readonly maxPlayerCount: number;
readonly expectedUserIds: string[];
readonly emptyRoomTtl: number;
readonly playerTtl: number;
readonly playerCount: number;
readonly customRoomPropertiesForLobby: CustomProperties;
}
export class Player {
readonly userId: string;
readonly actorId: number;
readonly isLocal: boolean;
readonly isMaster: boolean;
readonly isActive: boolean;
setCustomProperties(
properties: CustomProperties,
opts?: {
expectedValues?: CustomProperties;
}
): Promise<void>;
readonly customProperties: CustomProperties;
}
export class Room {
readonly name: string;
readonly open: boolean;
readonly visible: boolean;
readonly maxPlayerCount: number;
readonly master: Player;
readonly masterId: number;
readonly expectedUserIds: string[];
readonly playerList: Player[];
getPlayer(actorId: number): Player;
setCustomProperties(
properties: CustomProperties,
opts?: {
expectedValues?: CustomProperties;
}
): Promise<void>;
readonly customProperties: CustomProperties;
setOpen(open: boolean): Promise<void>;
setVisible(visible: boolean): Promise<void>;
setRoomMaxPlayerCount(count: number): Promise<void>;
setRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
clearRoomExpectedUserIds(): Promise<void>;
addRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
removeRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
setMaster(newMasterId: number): Promise<void>;
sendEvent(
eventId: number,
eventData?: CustomEventData,
options?: {
receiverGroup?: ReceiverGroup;
targetActorIds?: number[];
}
): Promise<void>;
kickPlayer(
actorId: number,
opts?: {
code?: number;
msg?: string;
}
): Promise<void>;
leave(): Promise<void>;
}
export class Client extends EventEmitter<PlayEvent> {
readonly room: Room;
readonly player: Player;
readonly lobbyRoomList: LobbyRoom[];
userId: string;
constructor(opts: {
appId: string;
appKey: string;
userId: string;
ssl?: boolean;
feature?: string;
gameVersion?: string;
playServer?: string;
});
connect(): Promise<Client>;
reconnect(): Promise<Client>;
reconnectAndRejoin(): Promise<Room>;
close(): Promise<void>;
joinLobby(): Promise<void>;
leaveLobby(): Promise<void>;
createRoom(opts?: {
roomName?: string;
roomOptions?: Object;
expectedUserIds?: string[];
}): Promise<Room>;
joinRoom(
roomName: string,
opts?: {
expectedUserIds?: string[];
}
): Promise<Room>;
rejoinRoom(roomName: string): Promise<Room>;
joinOrCreateRoom(
roomName: string,
opts?: {
roomOptions?: Object;
expectedUserIds: string[];
}
): Promise<Room>;
joinRandomRoom(opts?: {
matchProperties?: Object;
expectedUserIds?: string[];
}): Promise<Room>;
matchRandom(
piggybackPeerId: string,
opts?: { matchProperties?: Object; expectedUserIds?: string[] }
): Promise<LobbyRoom>;
setRoomOpen(open: boolean): Promise<void>;
setRoomVisible(visible: boolean): Promise<void>;
setRoomMaxPlayerCount(count: number): Promise<void>;
setRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
clearRoomExpectedUserIds(): Promise<void>;
addRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
removeRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
setMaster(newMasterId: number): Promise<void>;
sendEvent(
eventId: number,
eventData?: CustomEventData,
options?: {
receiverGroup?: ReceiverGroup;
targetActorIds?: number[];
}
): Promise<void>;
leaveRoom(): Promise<void>;
kickPlayer(
actorId: number,
opts?: {
code?: number;
msg?: string;
}
): Promise<void>;
pauseMessageQueue(): void;
resumeMessageQueue(): void;
}
export enum CreateRoomFlag {
FixedMaster = 1,
MasterUpdateRoomProperties = 2,
}
export function setAdapters(newAdapters: { WebSocket: Function }): void;
export enum LogLevel {
Debug = 'Debug',
Warn = 'Warn',
Error = 'Error',
}
export function setLogger(logger: {
Debug: (...args: any[]) => any;
Warn: (...args: any[]) => any;
Error: (...args: any[]) => any;
}): void;
export enum PlayErrorCode {
OPEN_WEBSOCKET_ERROR = 10001,
SEND_MESSAGE_STATE_ERROR = 10002,
}
export function registerType<T>(
type: T,
typeId: number,
serializeMethod: (obj: T) => Uint8Array,
deserializeMethod: (bytes: Uint8Array) => T
): void;
export function serializeObject(obj: Object): Uint8Array;
export function deserializeObject(bytes: Uint8Array): Object;
{ {
"ver": "2.0.0", "ver": "2.0.0",
"uuid": "758b0cbc-9597-4f72-b7d7-eafd5bfa5684", "uuid": "def7a5ea-e306-4527-a575-dd078a3e6a7d",
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "f8a6fa03-d3af-4c33-8c3b-2f21e7c5e175", "uuid": "5fbb2878-d748-459f-97ed-95067bd1642b",
"isPlugin": true, "isPlugin": true,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
...@@ -276,7 +276,12 @@ cc.Class({ ...@@ -276,7 +276,12 @@ cc.Class({
for(let i=0;i<this.data.images.length;i++){ for(let i=0;i<this.data.images.length;i++){
let image=this.data.images[i]; let image=this.data.images[i];
let tooth=await this.getSprNodeByUrl(image.img); let tooth=await this.getSprNodeByUrl(image.img);
parent.addChild(tooth); // parent.addChild(tooth);
parent.parent.addChild(tooth, 5);
tooth.x += parent.x;
tooth.y += parent.y;
// tooth.color = cc.Color.WHITE; // tooth.color = cc.Color.WHITE;
tooth.painted = null; tooth.painted = null;
} }
...@@ -470,12 +475,13 @@ cc.Class({ ...@@ -470,12 +475,13 @@ cc.Class({
console.log('~~~~~~~ 4'); console.log('~~~~~~~ 4');
this.networkHelper.startFrameSync(() => { // this.networkHelper.startFrameSync(() => {
}); // });
this.checkGameStart(); this.checkGameStart();
this.checkIsTeacher();
}, },
...@@ -492,8 +498,9 @@ cc.Class({ ...@@ -492,8 +498,9 @@ cc.Class({
console.log('this.isTeacher: ' , this.isTeacher); console.log('this.isTeacher: ' , this.isTeacher);
if (this.isTeacher) { if (this.isTeacher) {
// this.networkHelper.closeRoom(); this.networkHelper.closeRoom().then(() => {
this.addAiUser(); this.addAiUser();
});
} else { } else {
this.checkGameStart(); this.checkGameStart();
...@@ -515,16 +522,20 @@ cc.Class({ ...@@ -515,16 +522,20 @@ cc.Class({
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
const aiId = id + i; const aiId = id + i;
const data = { id: aiId, name: this.playerInfoData[i].name } const data = { playerId: aiId.toString(), name: this.playerInfoData[i].name }
this.sendServerEvent('add_ai', data); this.sendServerEvent('add_ai', data);
} }
}, },
checkIsTeacher(room) { checkIsTeacher() {
this.isTeacher = this.networkHelper.checkIsOwner(); // this.isTeacher = this.networkHelper.checkIsOwner();
return;
console.log("this.networkHelper.room.ownerId : ", this.networkHelper.room.ownerId );
console.log("this.playerId: ", this.playerId);
this.isTeacher = this.networkHelper.room.ownerId == this.playerId;
return
const playerList = this.networkHelper.room.roomInfo.playerList; const playerList = this.networkHelper.room.roomInfo.playerList;
...@@ -569,7 +580,9 @@ cc.Class({ ...@@ -569,7 +580,9 @@ cc.Class({
initServerAllUser(room) { initServerAllUser(room) {
// const roomInfo = room.roomInfo // const roomInfo = room.roomInfo
// this.serverAllUser = roomInfo.playerList; // this.serverAllUser = roomInfo.playerList;
this.serverAllUser = this.networkHelper.getOnlinePlayers(); this.serverAllUser = this.networkHelper.room.players;
console.log('this.serverAllUser: ', this.serverAllUser.toString());
console.log('this.serverAllUser.length: ', this.serverAllUser.length);
}, },
addNetworkListener(nh) { addNetworkListener(nh) {
...@@ -581,7 +594,7 @@ cc.Class({ ...@@ -581,7 +594,7 @@ cc.Class({
// } // }
this.log("playerJoin", (event)); this.log("playerJoin", (event));
this.onPlayerJoin(event.data); this.onPlayerJoin(event);
}); });
nh.on('playerLeave', (event) => { nh.on('playerLeave', (event) => {
...@@ -592,7 +605,9 @@ cc.Class({ ...@@ -592,7 +605,9 @@ cc.Class({
}); });
nh.on('frameEvent', (event) => { nh.on('frameEvent', (event) => {
const frameInfo = event.frameInfo; console.log(' on frameEvent``', event);
const frameInfo = event?.data?.frame?.items;
if (!frameInfo || frameInfo.length == 0) { if (!frameInfo || frameInfo.length == 0) {
return; return;
} }
...@@ -600,7 +615,7 @@ cc.Class({ ...@@ -600,7 +615,7 @@ cc.Class({
frameInfo.forEach((frameData) => { frameInfo.forEach((frameData) => {
frameData.data = JSON.parse(frameData.data); // frameData.data = JSON.parse(frameData.data);
const res = frameData.data; const res = frameData.data;
switch (res.type) { switch (res.type) {
...@@ -628,6 +643,11 @@ cc.Class({ ...@@ -628,6 +643,11 @@ cc.Class({
this.onAddAi(res.data); this.onAddAi(res.data);
return; return;
case 'refresh_player_list':
console.log(' on refresh_player_list')
this.onRefreshPlayerList(res.data);
return;
} }
}) })
...@@ -638,19 +658,25 @@ cc.Class({ ...@@ -638,19 +658,25 @@ cc.Class({
onPlayerJoin(data) { onPlayerJoin(data) {
let user = { id: data.joinPlayerId };
console.log(" in onPlayerJoin : ", data);
let user = { playerId: data.playerId };
console.log(' in onPlayerJoin 1 ', JSON.stringify(user)); console.log(' in onPlayerJoin 1 ', JSON.stringify(user));
const len = this.serverAllUser.length;
user.name = this.playerInfoData[len].name;
const playerList = data.roomInfo.playerList; const playerList = this.networkHelper.room.players;
console.log('playerList: ', playerList);
for (let i = 0; i < playerList.length; i++) { for (let i = 0; i < playerList.length; i++) {
if (playerList[i].id == user.id) { if (playerList[i].playerId == user.id) {
user.name = playerList[i].name; user.name = playerList[i].name;
console.log('in playerlist');
} }
} }
const len = this.serverAllUser.length;
user.name = this.playerInfoData[len].name;
console.log(' in onPlayerJoin 2 ', JSON.stringify(user)); console.log(' in onPlayerJoin 2 ', JSON.stringify(user));
...@@ -659,9 +685,16 @@ cc.Class({ ...@@ -659,9 +685,16 @@ cc.Class({
onAddAi(data) { onAddAi(data) {
console.log(' in onAddAi '); console.log(' in onAddAi data: ', data);
this.addUser({ id: data.id, name: data.name, isAi: true }) this.addUser({ playerId: data.playerId, name: data.name, isAi: true })
},
onRefreshPlayerList(data) {
console.log('onRefreshPlayerList data: ', data);
for (let i=0; i<data.length; i++) {
this.addUser(data[i]);
}
}, },
setPlayerResult(data) { setPlayerResult(data) {
...@@ -669,7 +702,7 @@ cc.Class({ ...@@ -669,7 +702,7 @@ cc.Class({
this.gameEndData[uuid] = data; this.gameEndData[uuid] = data;
for (let i = 0; i < this.serverAllUser.length; i++) { for (let i = 0; i < this.serverAllUser.length; i++) {
if (this.serverAllUser[i].id == uuid) { if (this.serverAllUser[i].playerId == uuid) {
this.serverAllUser[i].result = data; this.serverAllUser[i].result = data;
} }
} }
...@@ -797,7 +830,7 @@ cc.Class({ ...@@ -797,7 +830,7 @@ cc.Class({
console.log('this.serverAllUser[i].id: ', this.serverAllUser[i]); console.log('this.serverAllUser[i].id: ', this.serverAllUser[i]);
console.log('uuid: ', uuid); console.log('uuid: ', uuid);
if (this.serverAllUser[i].id == uuid) { if (this.serverAllUser[i].playerId == uuid) {
return this.serverAllUser[i].name; return this.serverAllUser[i].name;
} }
} }
...@@ -973,7 +1006,7 @@ cc.Class({ ...@@ -973,7 +1006,7 @@ cc.Class({
} }
const aiArr = this.getAiArr(); const aiArr = this.getAiArr();
if (aiArr.length == 0) { if (aiArr.length == 0 || true) {
this.teacherEnd(); this.teacherEnd();
return; return;
} }
...@@ -1335,9 +1368,9 @@ cc.Class({ ...@@ -1335,9 +1368,9 @@ cc.Class({
for (let i = 0; i < this.serverAllUser.length; i++) { for (let i = 0; i < this.serverAllUser.length; i++) {
const user = this.serverAllUser[i]; const user = this.serverAllUser[i];
const isSelf = user.id == this.playerId; const isSelf = user.playerId == this.playerId;
let headUrl = playerData[i].headUrl; let headUrl = playerData[i].headUrl;
if (isSelf) { if (isSelf && false) {
user.name = user.nick_name user.name = user.nick_name
headUrl = user.playerInfo.avatar; headUrl = user.playerInfo.avatar;
console.log('avatar: ', user.playerInfo.avatar) console.log('avatar: ', user.playerInfo.avatar)
...@@ -1389,8 +1422,10 @@ cc.Class({ ...@@ -1389,8 +1422,10 @@ cc.Class({
return; return;
} }
console.log('this.serverAllUser: ', this.serverAllUser);
console.log('user: ', user);
for (let i = 0; i < this.serverAllUser.length; i++) { for (let i = 0; i < this.serverAllUser.length; i++) {
if (this.serverAllUser[i].id == user.id) { if (this.serverAllUser[i].playerId == user.playerId) {
console.log(' 该用户已经存在 无需再加入。') console.log(' 该用户已经存在 无需再加入。')
return; return;
} }
...@@ -1401,15 +1436,20 @@ cc.Class({ ...@@ -1401,15 +1436,20 @@ cc.Class({
const len = this.serverAllUser.length; const len = this.serverAllUser.length;
const isSelf = this.playerId == user.id; const isSelf = this.playerId == user.playerId;
this.loadingScript.addPlayer(user.name, isSelf, this.playerInfoData[len - 1].headUrl); this.loadingScript.addPlayer(user.name, isSelf, this.playerInfoData[len - 1].headUrl);
// if (this.isTeacher) {
// setTimeout(() => { console.log('isSelf: ', isSelf);
// console.log(' aaa addUser, '); console.log('this.isTeacher: ', this.isTeacher);
console.log('user.isAi: ', user.isAi);
if (this.isTeacher && !user.isAi) {
setTimeout(() => {
this.sendServerEvent('refresh_player_list', this.serverAllUser);
// this.gameServer.addUser(user); // this.gameServer.addUser(user);
// }, 2000); }, 1);
// } }
}, },
...@@ -1448,6 +1488,10 @@ cc.Class({ ...@@ -1448,6 +1488,10 @@ cc.Class({
this.log("bg:"+bg1.name); this.log("bg:"+bg1.name);
bg1.getComponent(cc.Sprite).spriteFrame=spriteFrame; bg1.getComponent(cc.Sprite).spriteFrame=spriteFrame;
let bg2=this.paint2.getChildByName("alligator_img"); let bg2=this.paint2.getChildByName("alligator_img");
bg2.getComponent(cc.Sprite).spriteFrame=spriteFrame; bg2.getComponent(cc.Sprite).spriteFrame=spriteFrame;
...@@ -1537,6 +1581,8 @@ cc.Class({ ...@@ -1537,6 +1581,8 @@ cc.Class({
// this.gameEndData = JSON.parse( data ); // this.gameEndData = JSON.parse( data );
// } // }
this.isTimingShow = false;
if (this.isGameEnd) { if (this.isGameEnd) {
return; return;
} }
...@@ -1710,6 +1756,8 @@ cc.Class({ ...@@ -1710,6 +1756,8 @@ cc.Class({
rt.destroy(); rt.destroy();
} }
console.log('data~ : ', data);
if (data[3] > 0) { if (data[3] > 0) {
return true; return true;
} else { } else {
...@@ -1732,6 +1780,7 @@ cc.Class({ ...@@ -1732,6 +1780,7 @@ cc.Class({
}, },
sendResult() { sendResult() {
return;
const data = { teethDataArr: this.teethDataArr, uuid: this.playerId }; const data = { teethDataArr: this.teethDataArr, uuid: this.playerId };
if (window && window.courseware) { if (window && window.courseware) {
...@@ -1743,6 +1792,9 @@ cc.Class({ ...@@ -1743,6 +1792,9 @@ cc.Class({
console.log("sendServerEvent key: ", key); console.log("sendServerEvent key: ", key);
console.log("sendServerEvent data: ", data); console.log("sendServerEvent data: ", data);
// this.networkHelper.sendFrame({type:"aaaa", data:{a:"1"}});
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: key, type: key,
data data
......
import {asyncDelay} from './util.js' import { RandomInt } from "./util";
export class NetworkHelper { export class NetworkHelper {
_eventListeners: any = {}; _eventListeners: any = {};
ctor() { }
client: any;
playerId: any;
currentPlayer: any;
room: any;
roomType: any;
maxPlayers: any;
startFrameSyncCallback: any;
isStartFrameSync: any;
userInfo: any;
tempRoomPlayer: any;
ctor() {
}
on(eventName, func) { on(eventName, func) {
this._eventListeners[eventName] = func; this._eventListeners[eventName] = func;
} }
async init(roomType: string, maxPlayers: number) { async init(roomType: string, maxPlayers: number) {
// 人数只支持2~10个 ~~ await this.initRoom();
return await this.joinRoom(roomType, maxPlayers);
this.userInfo = await this.initUserInfo();
console.log('this.userInfo: ', this.userInfo);
this.maxPlayers = maxPlayers;
this.roomType = roomType;
await this.initEngine();
this.initTempRoomPlayer();
// await this.initRoom();
return this.userInfo.id;
} }
initTempRoomPlayer() { async startGame() {
const playerInfo = this.initPlayerInfo(); await this.startFrameSync();
this.userInfo.playerInfo = playerInfo; await this.closeRoom();
this.tempRoomPlayer = [ this.userInfo ];
} }
initUserInfo() { async stopGame() {
await this.stopFrameSync();
return new Promise((resolve, reject) => { await this.closeRoom();
if ( cc.find('middleLayer') && cc.find('middleLayer').getComponent('middleLayer')?.getUserInfo ) { await this.leaveRoom();
cc.find('middleLayer').getComponent('middleLayer').getUserInfo().then((res)=> {
resolve(res);
})
} else {
setTimeout(() => {
const userInfo = {
nick_name: '拼读达人',
avatar_url: '1',
id: 'id_' + new Date().getTime()
};
resolve(userInfo);
}, 100);
}
})
} }
async initEngine() { listenerInited = false;
const client = new window.GOBE.Client({ room: any;
clientId: '860627598634404416',// 客户端ID client: any;
clientSecret: '83B0DCE6407CBEFAD5786BAC07A73EBAF8E688E2CABA779724FC000C0714C8E7',// 客户端密钥 async initRoom() {
appId: '105878157',// 应用的ID const client = new globalThis.Play.Client({
openId: this.userInfo.id,// 玩家ID appId: "JCKc6bU8FywdjIPupjNH8Jwx-gzGzoHsz",
appKey: "WUrRDpb46z2qFLsUNbhknYcP",
userId: `${new Date().getTime()}_${RandomInt(100000000)}`,
playServer: 'https://lyn5nahs.lc-cn-n1-shared.com'
}); });
console.log('client = ', client);
await client.connect();
this.client = client; this.client = client;
console.log('连接成功');
return new Promise((resolve, reject) => {
client.init().then(() => {
// 初始化成功
console.log(' 华为 对战联机引擎 初始化成功')
console.log('``client: ', client);
this.playerId = client.playerId;
resolve('');
}).catch((e) => {
// 初始化失败
console.log(' 华为 对战联机引擎 初始化失败')
reject();
});
})
} }
async initRoom() { player: any;
joinRoom(roomType: string, maxPlayers: number) {
console.log('初始化 房间')
const playerInfo = this.initPlayerInfo();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const roomProp = { roomType, maxPlayers };
this.client.joinRandomRoom({
this.client.matchRoom({ matchProperties: roomProp,
matchParams: { }).then((room) => {
matchRule: 'match_rule_' + this.maxPlayers, resolve(this.onJoinRoomSuccess(room));
// matchRule2: 'xxxx', }).catch((error) => {
}, console.log('加入房间失败');
roomType: this.roomType, if (error.code == 4301) {
customRoomProperties: 'customRoomProperties_xxx', const options = {
// roomStatus: ROOM_STATE_IDLE, visible: true,
maxPlayers: this.maxPlayers, playerTtl: 0,
emptyRoomTtl: 0,
},{customPlayerStatus: 0, customPlayerProperties: JSON.stringify(playerInfo)}).then((room) => { maxPlayerCount: maxPlayers,
// 房间匹配成功 customRoomProperties: roomProp,
console.log('房间匹配成功: ', room); customRoomPropertyKeysForLobby: ['roomType', 'maxPlayers'],
flag: globalThis.Play.CreateRoomFlag.MasterUpdateRoomProperties
this.currentPlayer = room.player; };
this.room = room; this.client.createRoom({
this.addRoomListener(room); roomOptions: options,
this.initRoomPlayerInfo(); }).then((room) => {
resolve(this.onJoinRoomSuccess(room));
resolve(''); }).catch((error) => {
console.error(error.code, error.detail);
}).catch((e) => {
// 房间匹配失败
console.log(' in initRoom error:', e)
reject();
}); });
})
} }
});
initRoomPlayerInfo() { });
const players = this.room.players;
players.forEach(p => {
this.setCustomPlayerProperties(p);
})
} }
initPlayerInfo() { onJoinRoomSuccess(room: globalThis.Play.Room) {
console.log('加入房间成功 room = ', room);
// 初始化玩家基础数据 const playerMe = room.playerList.find(player => player.isLocal);
const masterPlayer = room.playerList.find(player => player.isMaster);
const masterId = masterPlayer.userId;
const playerId = playerMe.userId;
this.room = new FakeRoom(masterId);
this.room.players.push(this.room.player);
this.player = this.room.player;
const nick_name = this.userInfo?.nick_name || '拼读达人'; this.client.on(globalThis.Play.Event.PLAYER_ROOM_LEFT, (event) => {
const avatar_url = this.userInfo?.avatar_url || '1'; this.onLeaveRoom({ data: { leavePlayerId: event.leftPlayer.userId } });
const avatar = this.getAvatar(avatar_url); });
const playerInfo = { this.client.on(globalThis.Play.Event.PLAYER_ROOM_JOINED, (event) => {
playerId: this.playerId, this.onJoinRoom({ playerId: event.newPlayer.userId });
matchParams: { });
level: 1, this.client.on(globalThis.Play.Event.CUSTOM_EVENT, (event) => {
}, this.onRecvFrame({ data: event.eventData });
});
name: nick_name, // this.room.onDisconnect(this.onDisconnect.bind(this));
avatar, // this.room.onDismiss(this.onDisconnect.bind(this));
customPlayerStatus: 0, return playerId;
};
if (this.userInfo) {
this.userInfo.playerId = this.playerId;
} }
return playerInfo; async leaveRoom() {
await this.client.close();
console.log("退房成功");
} }
getAvatar(avatar_url) { async dismissRoom() {
let avatar = 'http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png'; if (this.room.ownerId == this.player.id) {
if (cc.find('middleLayer') && cc.find('middleLayer').getComponent('middleLayer')?.getHeadUrl) { console.log("房间已解散");
avatar = cc.find('middleLayer').getComponent('middleLayer').getHeadUrl(avatar_url);
} }
return avatar;
} }
addRoomListener(room) { async closeRoom() {
// 设置房间不可见
// 添加房间玩家进入监听 await this.client.setRoomVisible(false);
room.onJoin((playerInfo) => { console.log(this.client.room.visible);
//有玩家加入房间,做相关游戏逻辑处理
console.log(' onJoin :', playerInfo);
this.playerJoin(playerInfo);
});
// 添加帧同步开始通知回调
room.onStartFrameSync(() => {
// 接收帧同步开始通知,处理游戏逻辑
console.log("接收帧同步 开始")
if (this.startFrameSyncCallback) {
this.startFrameSyncCallback.call();
}
this.isStartFrameSync = true;
});
// 添加帧同步停止通知回调
room.onStopFrameSync(() => {
// 接收帧同步停止通知,处理游戏逻辑
console.log("接收帧同步 停止")
});
// 添加接收帧同步信息回调
room.onRecvFrame((msg) => {
// 处理帧数据msg
if (this._eventListeners['frameEvent']) {
this._eventListeners['frameEvent'](msg);
} }
});
// 离开房间事件 async startFrameSync() {
room.onLeave((playerInfo) => { console.log("开始帧同步成功");
// 有玩家离开房间,做相关游戏逻辑处理
console.log(' onLeave :', playerInfo);
this.updateRoom();
if (this._eventListeners['playerLeave']) {
this._eventListeners['playerLeave'](playerInfo);
} }
});
async stopFrameSync() {
console.log("停止帧同步成功");
} }
playerJoin(data) { sendFrame(data: any) {
// 有玩家加入 this.client.sendEvent(0, { frame: { items: [{ data: data }] } }, {
this.updateRoom(() => { receiverGroup: globalThis.Play.ReceiverGroup.All,
});
const playerData = this.getRoomPlayerById(data.playerId);
if (!playerData) {
return;
} }
this.setCustomPlayerProperties(playerData); onJoinRoom(event) {
this._eventListeners['playerJoin'](playerData); console.log("新玩家加入", event);
if (this._eventListeners["playerJoin"]) {
this._eventListeners["playerJoin"](event);
}
this.room.players.forEach(player => {
console.log('player.playerId = ', player.playerId);
}); });
} }
onLeaveRoom(event) {
setCustomPlayerProperties(playerData) { console.log("onLeaveRoom");
// 兼容老模板 if (this._eventListeners["playerLeave"]) {
if ( !playerData.playerInfo) { this._eventListeners["playerLeave"](event);
console.log('string : ', playerData.customPlayerProperties);
playerData.playerInfo = JSON.parse(playerData.customPlayerProperties);
} }
console.log("玩家退出", event.data.leavePlayerId);
} }
onRecvFromClient() { }
onDisconnect(event) {
leaveRoom() { this.log("玩家掉线了: " + JSON.stringify(event));
if (this._eventListeners["playerOffLine"]) {
// 离开房间 this._eventListeners["playerOffLine"](event);
this.client.leaveRoom().then((client) => {
// 退出房间成功
console.log(' 退出房间成功 ')
console.log(' client: ', client);
}).catch((e) => {
// 退出房间失败
console.log(' 退出房间失败 ')
});
} }
updateRoom(cb = null) {
console.log('in updateRoom');
// 更新一下房间数据
this.room.update().then(() => {
// 更新玩家房间信息成功,做相关的游戏处理逻辑
console.log('update this.room: ', this.room);
// this.checkCanStart();
cb && cb();
}).catch(() => {
// 更新玩家房间信息失败
});
} }
getOnlinePlayers() { onRecvFrame(event) {
return this.tempRoomPlayer; if (this._eventListeners["frameEvent"]) {
this._eventListeners["frameEvent"](event);
// 获取房间中 还在线上的玩家列表
const onlinePlayers = [];
const players = this.room.config.players;
for (let i=0; i<players.length; i++) {
if (players[i].status == 1) {
onlinePlayers.push(players[i]);
} }
} }
return onlinePlayers onStartFrameSync(event) {
console.log('onStartFrameSync');
if (this._eventListeners["gameStart"]) {
this._eventListeners["gameStart"](event);
} }
checkIsOwner() {
return true;
// 检查是不是房主 之前房主随时有掉线的可能
const onlinePlayers = this.getOnlinePlayers();
const firstPlayer = onlinePlayers[0];
return firstPlayer.playerId == this.playerId;
} }
onStopFrameSync(event) { }
onRecvFromGameSvr() { }
getRoomPlayerById(id) { async onDestroy() {
return this.tempRoomPlayer[0] try {
console.log("onDestroy1");
// 获取房间中特定id的玩家 // MGOBE.Listener.clear();
const players = this.room.config.players; this.stopFrameSync();
const player = players.find(p => { this.closeRoom();
return p.playerId == id; this.dismissRoom();
}) this.leaveRoom();
return player; console.log("onDestroy2");
} catch (e) {
console.log(JSON.stringify(e));
} }
startFrameSync(cb=null) {
cb();
return;
console.log('开启帧同步 ..');
if (this.isStartFrameSync) {
console.log('开启帧同步 .. 1');
return;
} }
if (this.startFrameSyncCallback) { log(str) {
return; const node = cc.find("middleLayer");
if (node) {
node.getComponent("middleLayer").log(str);
} else {
cc.log(str);
} }
// 开启帧同步
if (cb) {
this.startFrameSyncCallback = cb;
} }
this.room.startFrameSync();
callNetworkApiGet(baseUrl, uri, data, callBack) {
let queryStr = "?";
const params = [];
for (const key in data) {
if (Object.hasOwnProperty.call(data, key)) {
params.push(`${key}=${data[key]}`);
} }
stopGame() {
console.log('停止帧同步 ..');
// 向联机对战后端发送停止帧同步请求
this.room.stopFrameSync();
} }
queryStr += params.join("&");
sendFrame(data: any) { const xhr = new XMLHttpRequest();
const frameInfo = [{data: JSON.stringify(data)}]; xhr.onreadystatechange = () => {
this._eventListeners['frameEvent']({frameInfo}); if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 400) {
return; callBack(xhr.responseText);
// 发送帧数据 }
this.room.sendFrame(JSON.stringify(data), err => { };
if (err.code != 0) { const url = `${baseUrl}${uri}${queryStr}`;
console.log("err", err) console.log("url = " + url);
xhr.open("GET", url, true);
xhr.send();
} }
}
export function asyncDelay(time) {
return new Promise((resolve, reject) => {
cc.tween(cc.find("Canvas"))
.delay(time)
.call(() => {
resolve(null);
})
.start();
}); });
}
class FakeRoom {
ownerId;
players = [];
player: any;
roomInfo;
constructor(playerId) {
this.player = { playerId: playerId };
this.ownerId = playerId;
this.roomInfo = { owner: playerId }
} }
} }
\ No newline at end of file
import {asyncDelay} from './util.js'
export class NetworkHelper {
_eventListeners: any = {};
client: any;
playerId: any;
currentPlayer: any;
room: any;
roomType: any;
maxPlayers: any;
startFrameSyncCallback: any;
isStartFrameSync: any;
userInfo: any;
tempRoomPlayer: any;
ctor() {
}
on(eventName, func) {
this._eventListeners[eventName] = func;
}
async init(roomType: string, maxPlayers: number) {
// 人数只支持2~10个 ~~
this.userInfo = await this.initUserInfo();
console.log('this.userInfo: ', this.userInfo);
this.maxPlayers = maxPlayers;
this.roomType = roomType;
await this.initEngine();
this.initTempRoomPlayer();
// await this.initRoom();
return this.userInfo.id;
}
initTempRoomPlayer() {
const playerInfo = this.initPlayerInfo();
this.userInfo.playerInfo = playerInfo;
this.tempRoomPlayer = [ this.userInfo ];
}
initUserInfo() {
return new Promise((resolve, reject) => {
if ( cc.find('middleLayer') && cc.find('middleLayer').getComponent('middleLayer')?.getUserInfo ) {
cc.find('middleLayer').getComponent('middleLayer').getUserInfo().then((res)=> {
resolve(res);
})
} else {
setTimeout(() => {
const userInfo = {
nick_name: '拼读达人',
avatar_url: '1',
id: 'id_' + new Date().getTime()
};
resolve(userInfo);
}, 100);
}
})
}
async initEngine() {
const client = new window.GOBE.Client({
clientId: '860627598634404416',// 客户端ID
clientSecret: '83B0DCE6407CBEFAD5786BAC07A73EBAF8E688E2CABA779724FC000C0714C8E7',// 客户端密钥
appId: '105878157',// 应用的ID
openId: this.userInfo.id,// 玩家ID
});
this.client = client;
return new Promise((resolve, reject) => {
client.init().then(() => {
// 初始化成功
console.log(' 华为 对战联机引擎 初始化成功')
console.log('``client: ', client);
this.playerId = client.playerId;
resolve('');
}).catch((e) => {
// 初始化失败
console.log(' 华为 对战联机引擎 初始化失败')
reject();
});
})
}
async initRoom() {
console.log('初始化 房间')
const playerInfo = this.initPlayerInfo();
return new Promise((resolve, reject) => {
this.client.matchRoom({
matchParams: {
matchRule: 'match_rule_' + this.maxPlayers,
// matchRule2: 'xxxx',
},
roomType: this.roomType,
customRoomProperties: 'customRoomProperties_xxx',
// roomStatus: ROOM_STATE_IDLE,
maxPlayers: this.maxPlayers,
},{customPlayerStatus: 0, customPlayerProperties: JSON.stringify(playerInfo)}).then((room) => {
// 房间匹配成功
console.log('房间匹配成功: ', room);
this.currentPlayer = room.player;
this.room = room;
this.addRoomListener(room);
this.initRoomPlayerInfo();
resolve('');
}).catch((e) => {
// 房间匹配失败
console.log(' in initRoom error:', e)
reject();
});
})
}
initRoomPlayerInfo() {
const players = this.room.players;
players.forEach(p => {
this.setCustomPlayerProperties(p);
})
}
initPlayerInfo() {
// 初始化玩家基础数据
const nick_name = this.userInfo?.nick_name || '拼读达人';
const avatar_url = this.userInfo?.avatar_url || '1';
const avatar = this.getAvatar(avatar_url);
const playerInfo = {
playerId: this.playerId,
matchParams: {
level: 1,
},
name: nick_name,
avatar,
customPlayerStatus: 0,
};
if (this.userInfo) {
this.userInfo.playerId = this.playerId;
}
return playerInfo;
}
getAvatar(avatar_url) {
let avatar = 'http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png';
if (cc.find('middleLayer') && cc.find('middleLayer').getComponent('middleLayer')?.getHeadUrl) {
avatar = cc.find('middleLayer').getComponent('middleLayer').getHeadUrl(avatar_url);
}
return avatar;
}
addRoomListener(room) {
// 添加房间玩家进入监听
room.onJoin((playerInfo) => {
//有玩家加入房间,做相关游戏逻辑处理
console.log(' onJoin :', playerInfo);
this.playerJoin(playerInfo);
});
// 添加帧同步开始通知回调
room.onStartFrameSync(() => {
// 接收帧同步开始通知,处理游戏逻辑
console.log("接收帧同步 开始")
if (this.startFrameSyncCallback) {
this.startFrameSyncCallback.call();
}
this.isStartFrameSync = true;
});
// 添加帧同步停止通知回调
room.onStopFrameSync(() => {
// 接收帧同步停止通知,处理游戏逻辑
console.log("接收帧同步 停止")
});
// 添加接收帧同步信息回调
room.onRecvFrame((msg) => {
// 处理帧数据msg
if (this._eventListeners['frameEvent']) {
this._eventListeners['frameEvent'](msg);
}
});
// 离开房间事件
room.onLeave((playerInfo) => {
// 有玩家离开房间,做相关游戏逻辑处理
console.log(' onLeave :', playerInfo);
this.updateRoom();
if (this._eventListeners['playerLeave']) {
this._eventListeners['playerLeave'](playerInfo);
}
});
}
playerJoin(data) {
// 有玩家加入
this.updateRoom(() => {
const playerData = this.getRoomPlayerById(data.playerId);
if (!playerData) {
return;
}
this.setCustomPlayerProperties(playerData);
this._eventListeners['playerJoin'](playerData);
});
}
setCustomPlayerProperties(playerData) {
// 兼容老模板
if ( !playerData.playerInfo) {
console.log('string : ', playerData.customPlayerProperties);
playerData.playerInfo = JSON.parse(playerData.customPlayerProperties);
}
}
leaveRoom() {
// 离开房间
this.client.leaveRoom().then((client) => {
// 退出房间成功
console.log(' 退出房间成功 ')
console.log(' client: ', client);
}).catch((e) => {
// 退出房间失败
console.log(' 退出房间失败 ')
});
}
updateRoom(cb = null) {
console.log('in updateRoom');
// 更新一下房间数据
this.room.update().then(() => {
// 更新玩家房间信息成功,做相关的游戏处理逻辑
console.log('update this.room: ', this.room);
// this.checkCanStart();
cb && cb();
}).catch(() => {
// 更新玩家房间信息失败
});
}
getOnlinePlayers() {
return this.tempRoomPlayer;
// 获取房间中 还在线上的玩家列表
const onlinePlayers = [];
const players = this.room.config.players;
for (let i=0; i<players.length; i++) {
if (players[i].status == 1) {
onlinePlayers.push(players[i]);
}
}
return onlinePlayers
}
checkIsOwner() {
return true;
// 检查是不是房主 之前房主随时有掉线的可能
const onlinePlayers = this.getOnlinePlayers();
const firstPlayer = onlinePlayers[0];
return firstPlayer.playerId == this.playerId;
}
getRoomPlayerById(id) {
return this.tempRoomPlayer[0]
// 获取房间中特定id的玩家
const players = this.room.config.players;
const player = players.find(p => {
return p.playerId == id;
})
return player;
}
startFrameSync(cb=null) {
cb();
return;
console.log('开启帧同步 ..');
if (this.isStartFrameSync) {
console.log('开启帧同步 .. 1');
return;
}
if (this.startFrameSyncCallback) {
return;
}
// 开启帧同步
if (cb) {
this.startFrameSyncCallback = cb;
}
this.room.startFrameSync();
}
stopGame() {
console.log('停止帧同步 ..');
// 向联机对战后端发送停止帧同步请求
this.room.stopFrameSync();
}
sendFrame(data: any) {
const frameInfo = [{data: JSON.stringify(data)}];
this._eventListeners['frameEvent']({frameInfo});
return;
// 发送帧数据
this.room.sendFrame(JSON.stringify(data), err => {
if (err.code != 0) {
console.log("err", err)
}
});
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "24e2eb8f-4ebd-4080-978f-371087a3f7f9",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment