shoehive
Version:
WebSocket-based multiplayer game framework for real-time, event-driven gameplay
22 lines (21 loc) • 894 B
TypeScript
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;
/**
* Process a message from the client.
* @param player - The player object
* @param messageStr - The message string to process
*/
processMessage(player: Player, messageStr: string): void;
}