UNPKG

shoehive

Version:

WebSocket-based multiplayer game framework for real-time, event-driven gameplay

34 lines (33 loc) 1.21 kB
import { Player } from "../core/Player"; import { EventBus } from "./EventBus"; export declare class MessageRouter { private eventBus; private commandHandlers; constructor(eventBus: EventBus); /** * Register a command handler for a specific action. For example, if you * want a user to be able to make a choice, you could register `game:choice:make` * and then handle it in your game logic. * @param action - The action to register the handler for * @param handler - The handler function to be called when the action is received */ registerCommandHandler(action: string, handler: (player: Player, data: any) => void): void; /** * Register handlers for state request commands */ private registerStateCommandHandlers; /** * Register handlers for lobby commands */ private registerLobbyCommandHandlers; /** * Register handlers for table commands */ private registerTableCommandHandlers; /** * Process a message from the client. * @param player - The player object * @param messageStr - The message string to process */ processMessage(player: Player, messageStr: string): void; }