v0.8.2

Class: MessageRouter

Table of contents

Constructors

Methods

Constructors

constructor

new MessageRouter(eventBus): MessageRouter

Parameters

Name Type
eventBus EventBus

Returns

MessageRouter

Methods

processMessage

processMessage(player, messageStr): void

Process a message from the client.

Parameters

Name Type Description
player Player The player object
messageStr string The message string to process

Returns

void


registerCommandHandler

registerCommandHandler(action, handler): 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 Description
action string The action to register the handler for
handler (player: Player, data: any) => void The handler function to be called when the action is received

Returns

void