v0.10.0

Class: MessageRouter

Table of contents

Constructors

Methods

Constructors

constructor

new MessageRouter(eventBus): MessageRouter

Parameters

Name Type
eventBus EventBus

Returns

MessageRouter

Methods

processMessage

processMessage(«destructured»): void

Process a message from the client.

Parameters

Name Type
«destructured» Object
› messageStr string
› player Player

Returns

void


registerCommandHandler

registerCommandHandler(«destructured»): void

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.

Parameters

Name Type
«destructured» Object
› action string
› handler (player: Player, data: Record<string, unknown>) => void

Returns

void