@heyvr/sdk-arena
Version:
The SDK for heyVR's arena system.
71 lines (70 loc) • 3.02 kB
TypeScript
import { ArenaConfiguration, Lobby as LobbyInterface, PlayerList } from "./types";
import * as Colyseus from "colyseus.js";
import { BaseLobby } from "./BaseLobby";
export declare class Lobby extends BaseLobby<typeof Lobby.events[number]> implements LobbyInterface {
static readonly events: readonly ["command.kick.result", "command.ban.result", "command.unban.result", "command.listPlayers.result", "command.username.result", "communication.mute.result", "communication.unmute.result", "communication.allChat.result", "communication.teamChat.result", "communication.whisper.result", "system.message", "system.players.sync"];
private static instance?;
private static room?;
private colyseus;
private username?;
constructor(colyseus: Colyseus.Client);
get actions(): {
listPlayers: () => Promise<PlayerList>;
abandon: () => void;
disconnect: () => void;
reconnect: () => Promise<Lobby>;
destroy: () => void;
};
get commands(): {
kickPlayer: (username: string) => Promise<string>;
banPlayer: (username: string) => Promise<string>;
unbanPlayer: (username: string) => Promise<string>;
};
get communications(): {
allChat: (message: string) => Promise<string>;
teamChat: (message: string, team: string) => Promise<string>;
whisper: (message: string, username: string) => Promise<string>;
mute: (username: string) => Promise<string>;
unmute: (username: string) => Promise<string>;
call: () => never;
hangUp: () => never;
onMessage: (callback: (input: {
message: string;
senderId: string;
senderUsername: string;
whisper: boolean;
team: boolean;
}) => void) => void;
};
get data(): {
sendToAll: (data: any) => void;
sendToTeam: (data: any, team: string) => void;
onReceiveAll: (callback: (payload: any) => void) => void;
onReceiveTeam: (callback: (payload: any) => void) => void;
};
get events(): {
onDisconnect: (callback: (code: number) => void) => void;
onError: (callback: (code: number, message?: string) => void) => void;
onMessage: (callback: (code: string, message: string) => void) => void;
onPlayerSync: (callback: (result: {
event: 'join' | 'leave';
username: string;
sessionId: string;
}) => void) => void;
};
get session(): {
userId: string;
lobbyId: string;
username: string;
};
get state(): {
readonly current: void;
onChange: (callback: (state: any) => void) => void;
};
static create(colyseus: Colyseus.Client, config: Omit<ArenaConfiguration, 'lobby'>): Promise<Lobby>;
destroy(): void;
static getInstance(): Lobby;
private getRoom;
static join(colyseus: Colyseus.Client, config: Omit<ArenaConfiguration, 'name'>): Promise<Lobby>;
private registerListeners;
}