HuaweiDemo/goberts/GOBERTS.d.ts

406 lines
9.2 KiB
TypeScript
Raw Permalink Normal View History

2023-11-07 01:17:57 +00:00
export declare interface ActionArgs {
sender: string;
gameData: string;
roomId: string;
SDK: {
/**
*
* @param beginFrameId -
* @param size -
*/
requestFrame: (beginFrameId: number, size: number) => Promise<void>;
sendData: (data: string, players?: string[]) => Promise<void>;
setCache: (key: string, value: string, expireTime: number) => Promise<void>;
getCache: (key: string) => Promise<CacheValue>;
deleteCache: (key: string) => Promise<void>;
setCacheIfNotExist: (key: string, value: string, expireTime: number) => Promise<void>;
getRoomInfo: () => Promise<RoomInfo>;
log: {
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
};
updateRoomProperties: (updateRoomInfo: UpdateRoomInfo) => Promise<void>;
removePlayer: (playerId: string) => Promise<void>;
dismiss: () => Promise<void>;
getAutoFrame: () => boolean;
getFrameRate: () => number;
};
}
declare interface ArgsConfig {
sender: string;
roomId: string;
appId: string;
ticket: string;
domain: string;
projectId: string;
gameData?: string;
autoFrame: boolean;
frameRate: number;
frameRequesting: boolean;
frameRequestSize: number;
logger?: any;
}
export declare const enum AutoFrame {
AUTO_FRAME_OFF = 0,
AUTO_FRAME_ON = 1
}
declare interface BaseResponse {
ret: {
code: number;
msg?: string;
};
}
export declare interface CacheValue {
value?: string;
}
declare interface CacheValue_2 {
value?: string;
}
export declare type CommonFunc = (args: ActionArgs) => void;
declare interface CreateChannelResponse extends BaseResponse {
data: CreateChannelResponseData;
}
declare interface CreateChannelResponseData {
setupTicket: string;
joinTicket: string;
}
export declare type ErrorFunc = (error: GOBEError, args: ActionArgs) => 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;
}
export declare type FramePlayerInfoFunc = (playerInfo: FramePlayerInfo, args: ActionArgs) => void;
/**
*
* @public
*/
export declare interface FramePlayerPropInfo {
playerId: string;
customProp: string;
}
/**
*
* @public
*/
export declare interface FramePlayerStatusInfo {
playerId: string;
customStatus: number;
}
/**
*
* @public
*/
export declare interface FrameRoomInfo {
roomId: string;
roomName: string;
customProp: string;
roomOwner: string;
isPrivate: number;
isLock: boolean;
}
export declare interface GameServer {
onCreateRoom: CommonFunc;
onConnect?: CommonFunc;
onDisconnect?: CommonFunc;
onRecvFromClient?: CommonFunc;
onDestroyRoom: CommonFunc;
onJoin?: FramePlayerInfoFunc;
onLeave?: FramePlayerInfoFunc;
onStartFrameSync?: CommonFunc;
onStopFrameSync?: CommonFunc;
onRecvFrame?: OnRecvFrameFunc;
onRecvFromClientV2?: OnRecvFromClientFunc;
onRequestFrameError?: ErrorFunc;
onRoomPropertiesChange?: OnRoomPropertiesChangeFunc;
onUpdateCustomProperties?: OnUpdateCustomPropertiesFunc;
onUpdateCustomStatus?: OnUpdateCustomStatusFunc;
onRealTimeServerDisconnected?: CommonFunc;
onRealTimeServerConnected?: CommonFunc;
}
declare interface GetCacheResponse extends BaseResponse {
value?: string;
}
declare interface GetRoomInfoResponse extends BaseResponse {
roomInfo: RoomInfo_2;
}
export declare interface gobeDevloperCode {
appId: string;
gameServer: GameServer;
}
/**
*
* @public
*/
export declare class GOBEError extends Error {
code: number;
constructor(code: number, message?: string);
}
export declare const enum ImType {
ALL_PLAYERS_EXCEPT_ME = 1,
SPECIFILED_PLAYERS = 2
}
/**
* sdk接口定义文档
*/
declare interface MethodRoute {
createRoom: (request: ServerLessMethodRequest) => void;
}
export declare const myHandler: (event: serverInterface.ServerLessEvent, context: serverInterface.ServerLessContext, callback: (res: any) => void, logger: any) => void;
export declare type OnRecvFrameFunc = (msg: RecvFrameMessage | RecvFrameMessage[], args: ActionArgs) => void;
export declare type OnRecvFromClientFunc = (msg: RecvFromClientInfo, args: ActionArgs) => void;
export declare type OnRoomPropertiesChangeFunc = (msg: FrameRoomInfo, args: ActionArgs) => void;
export declare type OnUpdateCustomPropertiesFunc = (player: FramePlayerPropInfo, args: ActionArgs) => void;
export declare type OnUpdateCustomStatusFunc = (msg: FramePlayerStatusInfo, args: ActionArgs) => void;
export declare interface PlayerInfo {
playerId: string;
status?: number;
customPlayerStatus?: number;
customPlayerProperties?: string;
teamId?: string;
isRobot?: number;
robotName?: string;
matchParams?: Record<string, string>;
}
declare interface PlayerInfo_2 {
playerId: string;
status?: number;
customPlayerStatus?: number;
customPlayerProperties?: string;
teamId?: string;
isRobot?: number;
robotName?: string;
matchParams?: Record<string, string>;
}
/**
* 广
* @public
*/
export declare interface RecvFrameMessage extends ServerFrameMessage {
isReplay: boolean;
time: number;
}
/**
* 广
* @param roomId - ID
* @param sendPlayerId - playerId
* @param msg -
* @public
*/
export declare interface RecvFromClientInfo {
srcPlayer: string;
msg: string;
}
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;
}
declare interface RoomInfo_2 {
appId: string;
roomId: string;
roomType: string;
roomCode: string;
roomName: string;
roomStatus: number;
customRoomProperties: string;
ownerId: string;
maxPlayers: number;
players: PlayerInfo_2[];
router: RouterInfo_2;
isPrivate: number;
createTime: number;
}
export declare interface RouterInfo {
routerId: number;
routerType: number;
routerAddr: string;
}
declare interface RouterInfo_2 {
routerId: number;
routerType: number;
routerAddr: string;
}
/**
* ACK
*/
declare interface ServerAckMessage {
rtnCode: number;
msg: string;
}
/**
*
* @public
*/
export declare interface ServerFrameMessage {
currentRoomFrameId: number;
frameInfo: FrameInfo[];
ext: FrameExtInfo;
}
/**
*
* @public
*/
export declare interface ServerFramePlayerInfo extends FramePlayerInfo {
extraInfo?: string;
}
declare namespace serverInterface {
export {
MethodRoute,
ServerLessEvent,
ServerLessEventBody,
ServerLessEventBodyRequest,
ServerLessContext,
ServerLessMethodRequest,
ArgsConfig,
ServerAckMessage,
BaseResponse,
GetRoomInfoResponse,
CreateChannelResponse,
GetCacheResponse,
CreateChannelResponseData,
RoomInfo_2 as RoomInfo,
PlayerInfo_2 as PlayerInfo,
RouterInfo_2 as RouterInfo,
CacheValue_2 as CacheValue
}
}
declare interface ServerLessContext {
env: {
GOBE_EDGE_DOMAIN: string;
DEVELOPER_PROJECT_ID: string;
DEVELOPER_APP_ID: string;
WS_HEARTBEAT_CYCLE: string;
};
}
declare interface ServerLessEvent {
body: string;
headers: {
ticket: string;
};
}
declare interface ServerLessEventBody {
method: keyof MethodRoute;
request: string;
data: string;
}
declare interface ServerLessEventBodyRequest {
roomId: string;
operator?: string;
epAddress: string;
setupTicket: string;
joinTicket: string;
autoFrame: string;
frameRate: string;
}
declare interface ServerLessMethodRequest {
roomId: string;
operator?: string;
ticket: string;
domain: string;
data: string;
projectId: string;
logger: any;
appId: string;
epAddress: string;
setupTicket: string;
joinTicket: string;
autoFrame: string;
frameRate: string;
wsHeartbeatCycle: string;
}
/**
*
* @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 GOBERTS