HuaweiDemo/assets/script/libs/GOBE.d.ts

1340 lines
38 KiB
TypeScript
Raw Permalink Normal View History

2023-11-07 01:17:57 +00:00
export declare const enum AutoFrame {
AUTO_FRAME_OFF = 0,
AUTO_FRAME_ON = 1
}
/**
*
* @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 haInit(): void;
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;
get connection(): Connection;
protected addListener(key: number, value: Base): void;
protected removeListener(key: number): void;
get isReconnectStatus(): boolean;
setReconnectStatus(status: boolean): void;
get reconnectIntervalSeconds(): number;
private onMessage;
/**
* websocket
* @param routerAddress
* @param ticket
*/
private wsConnect;
/**
* js目前只支持wss
* @param protocol
* @param isReconnect
* @protected
*/
protected connect(protocol?: number, isReconnect?: boolean): Promise<void>;
protected onWsMessage(ev: MessageEvent): void;
protected onWsClose(ev: CloseEvent): void;
}
export declare interface BaseResponse {
rtnCode: number;
msg?: string;
}
/**
*
* @public
*/
export declare class Client extends Base {
private _auth;
private _room;
private _group;
private _pollInterval;
private _isMatching;
private _loginTimestamp;
private _initStatus;
onMatch: {
(this: any, cb: (onMatchResponse: OnMatchResponse) => any): EventEmitter<(onMatchResponse: OnMatchResponse) => any>;
emit(onMatchResponse: OnMatchResponse): void;
off(cb: (onMatchResponse: OnMatchResponse) => any): void;
clear(): void;
};
onInitResult: {
(this: any, cb: (resultCode: number) => any): EventEmitter<(resultCode: number) => any>;
emit(resultCode: number): void;
off(cb: (resultCode: number) => any): void;
clear(): void;
};
/**
*
* @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
* @privateRemarks lastRoomId
*/
dismissRoom(): Promise<Client>;
/**
*
*/
leaveGroup(): Promise<Client>;
/**
*
* @remarks
*/
dismissGroup(): Promise<Client>;
/**
* ID
* @param frameId - ID
*/
resetRoomFrameId(frameId: number): Promise<Client>;
/**
*
*/
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<MatchResponse>;
/**
*
* @param matchGroupConfig -
* @param playerConfig -
* @remarks 广
*/
matchGroup(matchGroupConfig: MatchGroupConfig, playerConfig?: PlayerConfig): Promise<MatchResponse>;
/**
*
* @param fn -
* @param matchType -
* @param playerConfig -
* @remarks 线/
*/
private matchStart;
/**
*
* @param playerConfig -
* @remarks onMatch监听
*/
matchQuery(playerConfig?: PlayerConfig): void;
/**
*
* @param matchResponse -
* @param playerConfig -
* @remarks
*/
private matchResponseHandler;
/**
*
* @remarks
*/
cancelMatch(): Promise<BaseResponse>;
/**
*
*/
removeAllListeners(): void;
/**
*
*/
destroy(): Promise<void>;
protected onStateChange(state: StateCode): Promise<void>;
protected onServerEventChange(serverEvent: ServerEvent): Promise<void>;
private checkMatching;
/**
* ws onmessage client
* @param ev
* @protected
*/
protected onWsMessage(ev: MessageEvent): void;
/**
* ws断开时触发
* @param ev
* @protected
*/
protected onWsClose(ev: CloseEvent): Promise<void>;
/**
* ws自动重连
* @private
*/
private autoReconnect;
/**
* Client监听的所有ws消息
* @private
*/
private removeAllListener;
}
/**
* Client类构造方法参数
* @param clientId - ID
* @param openId - ID
* @param appId - ID
* @param platform -
* @param cerPath - platform为CC_ANDROID时cer证书路径
* @param clientSecret -
* @param createSignature -
* @param accessToken - accessToken
* @public
*/
export declare interface ClientConfig {
clientId: string;
openId: string;
appId: string;
platform?: PlatformType;
cerPath?: string;
clientSecret?: string;
createSignature?: CreateSignature;
accessToken?: string;
}
declare class Connection {
static heartbeatCycle: number;
transport: Transport;
events: Partial<TransportEventMap>;
private heartbeatTimer;
constructor(Transport?: TransportConstructor);
connect(endpoint: string): void;
send(data: ArrayBuffer): void;
close(code?: number, reason?: string): void;
isOpen(): boolean;
isConnecting(): boolean;
isClosing(): boolean;
isClosed(): boolean;
removeAllListeners(): void;
startHeartbeat(): void;
stopHeartbeat(): void;
}
/**
*
* @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 isLock - 01
* @param roomType -
* @param roomName -
* @param matchParams -
* @param customRoomProperties -
* @public
*/
export declare interface CreateRoomConfig {
maxPlayers: number;
isPrivate?: number;
isLock?: number;
roomType?: string;
roomName?: string;
matchParams?: Record<string, string>;
customRoomProperties?: string;
}
/**
*
* @public
*/
export declare type CreateSignature = () => Promise<Signature>;
/**
*
* @public
*/
export declare enum ErrorCode {
COMMON_OK = 0,
COMMON_ERR = -1,
CLIENT_COMMON_ERR = -2,
AUTHENTICATION_FAILED = 2,
COMMON_REQUEST_PARAM_ERR = 1001,
REPEAT_REQUEST = 1002,
SDK_AUTO_REQUEST_FRAME_FAILED = 10002,
SDK_FRAME_ID_RANGE_ERR = 10003,
SDK_NOT_IN_ROOM = 90002,
SDK_MATCHING = 90008,
SDK_REQUESTING = 90010,
SDK_GROUP_MEMBERS_ERR = 90011,
GET_ACCESS_TOKEN_ERR = 95001,
ROOM_PLAYER_NOT_IN_ROOM = 101101,
ROOM_INFO_NOT_EXIST = 101103,
PLAYER_NOT_IN_CURRENT_ROOM = 101105,
PLAYER_ALREADY_IN_ANOTHER_ROOM = 101106,
PLAYERS_EXCEED_ROOM_MAX = 101107,
ROOM_OWNER_AND_PLAYER_MISMATCH = 101109,
MAX_PLAYERS_TOO_LARGE_OR_NEGATIVE = 101113,
ROOM_STARTED_FRAME_SYNC = 101114,
ROOM_STOPPED_FRAME_SYNC = 101115,
INVALID_ROOM = 101117,
INVALID_ROOM_STATUS = 101120,
REMOVE_SELF = 101121,
TOO_MANY_MATCHING_PARAMETERS = 101123,
TARGET_OWNER_NOT_IN_ROOM = 101132,
ONLINE_USERS_EXCEED_MAX = 101135,
ROOM_IS_LOCK = 101142,
PLAYER_NOT_IN_CURRENT_GROUP = 101201,
GROUP_NOT_EXIST = 101202,
ROOM_NOT_START_FRAME_SYNC = 102003,
OWNER_NOT_MATCH_GROUP = 101204,
GROUP_IS_LOCK = 101205,
GROUP_IS_FULL = 101206,
NEW_LEADER_NOT_IN_GROUP = 101208,
PLAYER_NOT_IN_ROOM = 102005,
ROOM_NOT_EXIST = 102008,
REQUEST_FRAME_NUMBER_OVERRUN = 102014,
INVALID_MESSAGE = 102016,
NO_VALID_TARGET_PLAYER = 102017,
INVALID_MESSAGE_LENGTH = 102018,
LOGIN_BUSY = 103001,
CLIENT_TRAFFIC_CONTROL = 103003,
CONNECTIONS_EXCEED_MAX = 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_ROOM_NULL = 104208,
PLAYER_MATCH_INVALID_TEAM = 104209,
PLAYER_NOT_IN_MATCH = 104211,
INVOKE_WISE_FUNCTION_FAILED = 105004,
JOIN_OR_CREATE_ROOM_FAILED = 91001
}
/**
*
* @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
* @param sync - true: false:
* @public
*/
export declare interface GetAvailableRoomsConfig {
roomType?: string;
offset?: number | string;
limit?: number;
sync?: boolean;
}
/**
*
* @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;
/**
* 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(config: GroupInfo);
/**
*
*/
query(): Promise<Group>;
/**
*
*/
leave(): Promise<void>;
/**
*
* @remarks
*/
dismiss(): Promise<void>;
/**
*
* @remarks
* @param config -
*/
updateGroup(config: UpdateGroupConfig): Promise<void>;
/**
*
* @param playerId - ID
* @remarks onLeave收到玩家被踢通知
*/
removePlayer(playerId: string): Promise<void>;
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>;
}
export declare interface MatchResponse extends BaseResponse {
roomId?: string;
}
/**
*
* @param matchParams - 5
* @param maxPlayers -
* @param roomType -
* @param customRoomProperties -
* @remarks maxPlayersroomTypecustomRoomProperties用于找不到匹配房间时创建房间
* @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>;
}
export declare interface OnMatchResponse extends BaseResponse {
room?: Room;
}
/**
*
* @public
*/
export declare enum PlatformType {
WEB = 0,
CC_ANDROID = 1,
OTHER = 7
}
/**
*
* @public
*/
export declare class Player extends Base {
customStatus?: number;
customProperties?: string;
onCustomStatusChangeSuccess: {
(this: any, cb: () => any): EventEmitter<() => any>;
emit(): void;
off(cb: () => any): void;
clear(): void;
};
onCustomStatusChangeFailed: {
(this: any, cb: (error: GOBEError) => any): EventEmitter<(error: GOBEError) => any>;
emit(error: GOBEError): void;
off(cb: (error: GOBEError) => any): void;
clear(): void;
};
onCustomPropertiesChangeSuccess: {
(this: any, cb: () => any): EventEmitter<() => any>;
emit(): void;
off(cb: () => any): void;
clear(): void;
};
onCustomPropertiesChangeFailed: {
(this: any, cb: (error: GOBEError) => any): EventEmitter<(error: GOBEError) => any>;
emit(error: GOBEError): void;
off(cb: (error: GOBEError) => any): void;
clear(): void;
};
constructor(customStatus?: number, customProperties?: string);
/**
*
*/
updateCustomStatus(status: number): void;
/**
*
*/
updateCustomProperties(customProperties: string): void;
protected onWsMessage(ev: MessageEvent): void;
protected onWsClose(ev: CloseEvent): void;
protected removeAllListener(): void;
}
/**
*
* @param customPlayerStatus -
* @param customPlayerProperties -
* @public
*/
export declare interface PlayerConfig {
customPlayerStatus?: number;
customPlayerProperties?: string;
}
/**
*
* @param playerId - ID
* @param status - 013线
* @param customPlayerStatus -
* @param customPlayerProperties -
* @param teamId - teamId
* @param isRobot - 01
* @param robotName -
* @param matchParams -
* @public
*/
export declare interface PlayerInfo {
playerId: string;
status?: number;
customPlayerStatus?: number;
customPlayerProperties?: string;
teamId?: string;
isRobot?: number;
robotName?: string;
matchParams?: Record<string, 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,
UPDATE_CUSTOM_STATUS = 18,
UPDATE_CUSTOM_PROPS = 19,
UPDATE_ROOM_PROPS = 20,
INSTANT_MESSAGE = 22,
INSTANT_MESSAGE_ACK = 23,
RT_TO_SERVER_MSG = 24,
RT_TO_SERVER_MSG_ACK = 25,
RT_TO_CLIENT_MSG = 26,
RT_TO_CLIENT_MSG_ACK = 27,
UPDATE_PLAYER_STATUS = 28,
UPDATE_PLAYER_STATUS_ACK = 29,
UPDATE_PLAYER_PROP = 30,
UPDATE_PLAYER_PROP_ACK = 31,
UPDATE_ROOM_PROP = 32,
UPDATE_ROOM_PROP_ACK = 33,
RTM_CHANNEL_SETUP = 34,
RTM_CHANNEL_DESTROY = 35,
JOIN_ROOM_REQ = 36,
JOIN_ROOM_ACK = 37,
WS_CLOSE = 1000
}
/**
* 线
* @public
*/
export declare class RandomUtils {
private mask;
private m;
private a;
private seed;
constructor(seed: number);
getNumber(): number;
}
/**
* 广
* @public
*/
export declare interface RecvFrameMessage extends ServerFrameMessage {
isReplay: boolean;
time: number;
}
/**
* 广
* @param roomId - ID
* @param sendPlayerId - playerId
* @param msg -
* @public
*/
export declare interface RecvFromClientInfo {
roomId: string;
sendPlayerId: string;
msg: string;
}
/**
* 广
* @param roomId - ID
* @param msg -
* @public
*/
export declare interface RecvFromServerInfo {
roomId: string;
msg: string;
}
/**
*
* @public
*/
export declare class Room extends Base {
static autoFrame: AutoFrame;
onConnect: {
(this: any, cb: (player: FramePlayerInfo) => any): EventEmitter<(player: FramePlayerInfo) => any>;
emit(player: FramePlayerInfo): void;
off(cb: (player: FramePlayerInfo) => any): void;
clear(): void;
};
onJoin: {
(this: any, cb: (player: FramePlayerInfo) => any): EventEmitter<(player: FramePlayerInfo) => any>;
emit(player: FramePlayerInfo): void;
off(cb: (player: FramePlayerInfo) => any): void;
clear(): void;
};
onJoinFailed: {
(this: any, cb: (error: GOBEError) => any): EventEmitter<(error: GOBEError) => any>;
emit(error: GOBEError): void;
off(cb: (error: GOBEError) => 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) => any): EventEmitter<(player: FramePlayerInfo, event?: CloseEvent) => any>;
emit(player: FramePlayerInfo, event?: CloseEvent | undefined): void;
off(cb: (player: FramePlayerInfo, event?: CloseEvent) => 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: RecvFrameMessage | RecvFrameMessage[]) => any): EventEmitter<(msg: RecvFrameMessage | RecvFrameMessage[]) => any>;
emit(msg: RecvFrameMessage | RecvFrameMessage[]): void;
off(cb: (msg: RecvFrameMessage | RecvFrameMessage[]) => 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;
};
onUpdateCustomStatus: {
(this: any, cb: (player: UpdateCustomStatusResponse) => any): EventEmitter<(player: UpdateCustomStatusResponse) => any>;
emit(player: UpdateCustomStatusResponse): void;
off(cb: (player: UpdateCustomStatusResponse) => any): void;
clear(): void;
};
onUpdateCustomProperties: {
(this: any, cb: (player: UpdateCustomPropertiesResponse) => any): EventEmitter<(player: UpdateCustomPropertiesResponse) => any>;
emit(player: UpdateCustomPropertiesResponse): void;
off(cb: (player: UpdateCustomPropertiesResponse) => any): void;
clear(): void;
};
onRoomPropertiesChange: {
(this: any, cb: (roomInfo: RoomInfo) => any): EventEmitter<(roomInfo: RoomInfo) => any>;
emit(roomInfo: RoomInfo): void;
off(cb: (roomInfo: RoomInfo) => any): void;
clear(): void;
};
onRecvFromClient: {
(this: any, cb: (recvFromClientInfo: RecvFromClientInfo) => any): EventEmitter<(recvFromClientInfo: RecvFromClientInfo) => any>;
emit(recvFromClientInfo: RecvFromClientInfo): void;
off(cb: (recvFromClientInfo: RecvFromClientInfo) => any): void;
clear(): void;
};
onRecvFromServer: {
(this: any, cb: (recvFromServerInfo: RecvFromServerInfo) => any): EventEmitter<(recvFromServerInfo: RecvFromServerInfo) => any>;
emit(recvFromServerInfo: RecvFromServerInfo): void;
off(cb: (recvFromServerInfo: RecvFromServerInfo) => any): void;
clear(): void;
};
onSendToClientFailed: {
(this: any, cb: (error: GOBEError) => any): EventEmitter<(error: GOBEError) => any>;
emit(error: GOBEError): void;
off(cb: (error: GOBEError) => any): void;
clear(): void;
};
onSendToServerFailed: {
(this: any, cb: (error: GOBEError) => any): EventEmitter<(error: GOBEError) => any>;
emit(error: GOBEError): void;
off(cb: (error: GOBEError) => any): void;
clear(): void;
};
onRoomPropertiesChangeFailed: {
(this: any, cb: (error: GOBEError) => any): EventEmitter<(error: GOBEError) => any>;
emit(error: GOBEError): void;
off(cb: (error: GOBEError) => any): void;
clear(): void;
};
private config;
private frameId;
private readonly frameRequestMaxSize;
private frameRequesting;
private frameRequestSize;
private frameRequestTimes;
private frameRequestList;
private autoFrameRequesting;
private autoRequestFrameFailed;
private isConnected;
private autoFrameRequestCacheList;
private initiativeLeaveRoomFlag;
private readonly _player;
private _client;
private delayCollectAnalyzer;
private currentServerFrameId;
/**
* 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;
/**
* 01
*/
get isPrivate(): number;
/**
*
*/
get isLock(): number;
/**
*
*/
get createTime(): number;
/**
*
*/
get isSyncing(): boolean;
/**
*
*/
get player(): Player;
/**
*
* @param client - Client实例
* @param config -
*/
constructor(client: Client, config: RoomInfo);
/**
*
* @param frameData -
*/
sendFrame(frameData: string | string[]): void;
/**
*
* @param beginFrameId -
* @param size -
*/
requestFrame(beginFrameId: number, size: number): void;
/**
* ID
* @param frameId - Id
*/
resetRoomFrameId(frameId: number): void;
/**
*
*/
removeAllListeners(): void;
/**
*
*/
reconnect(playerConfig?: PlayerConfig): Promise<void>;
/**
*
*/
startFrameSync(): Promise<void>;
/**
*
*/
stopFrameSync(): Promise<void>;
/**
*
*/
update(): Promise<Room>;
/**
*
* @param updateRoomInfo -
* @remarks
*/
updateRoomProperties(updateRoomInfo: UpdateRoomInfo): void;
/**
*
*/
leave(): Promise<void>;
/**
*
* @remarks
*/
dismiss(): Promise<void>;
/**
*
* @param playerId - ID
* @remarks
* @remarks
*/
removePlayer(playerId: string): Promise<void>;
/**
*
* @param sendToClientInfo -
*/
sendToClient(sendToClientInfo: SendToClientInfo): void;
/**
*
* @param msg -
*/
sendToServer(msg: string): void;
private clearRequestFrame;
protected onWsClose(ev: CloseEvent): Promise<void>;
protected onWsMessage(ev: MessageEvent): void;
private updateRoomPropertiesHandle;
private updateRoomPropAckHandle;
private frameSyncStartHandle;
private frameSyncStopHandle;
private preCheckBroadcastFrame;
private broadcastFrameDataHandle;
private queryFrameDataHandle;
private connectedMsgHandle;
private joinRoomACKHandle;
private leaveRoomMsgHandle;
private joinRoomMsgHandle;
private disconnectMsgHandle;
private dismissRoomMsgHandle;
private updatePlayerStatusHandle;
private updatePlayerPropertiesHandle;
private instantMessageHandle;
private instantMsgACKHandle;
private realtimeMsgACKHandle;
private queryFrameDataAckHandle;
private removeAllListener;
private addAllListener;
}
/**
*
* @public
* @param appId - ID
* @param roomId - ID
* @param roomType -
* @param roomCode -
* @param roomName -
* @param roomStatus - 01
* @param customRoomProperties -
* @param ownerId - ID
* @param maxPlayers -
* @param players -
* @param router -
* @param isPrivate -
* @param isLock - 01
* @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;
isLock: number;
createTime: number;
}
/**
*
* @public
*/
export declare interface RouterInfo {
routerId: number;
routerType: number;
routerAddr: string;
}
/**
*
* @param type - 012recvPlayerIdList的玩家
* @param msg -
* @param recvPlayerList - ID列表
* @public
*/
export declare interface SendToClientInfo {
type: number;
msg: string;
recvPlayerIdList?: string[];
}
/**
*
* @param eventType - 16789
* @param eventParam -
* @public
*/
export declare interface ServerEvent {
eventType: ServerEventCode;
eventParam?: string;
}
/**
*
* @public
*/
export declare const enum ServerEventCode {
DEFAULT = 0,
MATCH_START = 1,
JOIN_GROUP = 6,
LEAVE_GROUP = 7,
DISMISS_GROUP = 8,
UPDATE_GROUP = 9
}
/**
*
* @public
*/
export declare interface ServerFrameMessage {
currentRoomFrameId: number;
frameInfo: FrameInfo[];
ext: FrameExtInfo;
}
/**
*
* @public
*/
export declare interface ServerFramePlayerInfo extends FramePlayerInfo {
extraInfo?: string;
}
/**
*
* @param sign -
* @param nonce -
* @param timeStamp - ()
* @public
*/
export declare interface Signature {
sign: string;
nonce: string;
timeStamp: number;
}
/**
* SDK
* @public
*/
export declare const enum StateCode {
UNINITIALIZED = 0,
INITIALIZED = 1,
INROOM = 2,
SYNCING = 3
}
declare interface Transport {
connect(endpoint: string): void;
send(data: ArrayBuffer | Array<number>): void;
close(code?: number, reason?: string): void;
isOpen(): boolean;
isConnecting(): boolean;
isClosing(): boolean;
isClosed(): boolean;
removeAllListeners(): void;
}
declare interface TransportConstructor {
new (events: Partial<TransportEventMap>): Transport;
}
declare interface TransportEventMap {
onopen: ((ev: Event) => any) | null;
onmessage: ((ev: MessageEvent) => any) | null;
onclose: ((ev: CloseEvent) => any) | null;
onerror: ((ev: Event) => any) | null;
}
/**
*
* @public
*/
export declare interface UpdateCustomPropertiesResponse {
playerId: string;
customProperties: string;
}
/**
*
* @public
*/
export declare interface UpdateCustomStatusResponse {
playerId: string;
customStatus: number;
}
/**
*
* @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;
}
/**
*
* @public
* @param roomName -
* @param customRoomProperties -
* @param ownerId - ID
* @param isPrivate -
* @param isLock - 01
*/
export declare interface UpdateRoomInfo {
roomName?: string;
customRoomProperties?: string;
ownerId?: string;
isPrivate?: number;
isLock?: number;
}
export { }
export as namespace GOBE