UNPKG

@lobstar/preact

Version:

A collection of Preact hooks to use Lobstar library for network and lobby management for multiplayer web games

19 lines (18 loc) 789 B
import { GameSessionManager, GameSessionOptions, SessionState } from "@lobstar/core"; /** * Core hook that initializes and provides access to the GameSessionManager */ export declare function useGameSession(options?: GameSessionOptions): { session: GameSessionManager | null; host: (playerName: string, lobbyId?: string) => Promise<string>; join: (lobbyId: string, playerName: string) => Promise<void>; leave: () => void; setReady: (isReady: boolean) => void; startGame: () => void; endGame: () => void; kickPlayer: (playerId: string) => void; sendMessage: (peerId: string, data: unknown) => void; sendMessageToHost: (data: unknown) => void; broadcastMessage: (data: unknown, excludeSelf?: boolean) => void; sessionState: SessionState; };