Telegram(sender, receiver, message, delay, data)

Class for representing a telegram, an envelope which contains a message and certain metadata like sender and receiver. Part of the messaging system for game entities.

new Telegram(sender, receiver, message, delay, data)

Constructs a new telegram object.

Parameters:
Name Type Description
sender GameEntity

The sender.

receiver GameEntity

The receiver.

message String

The actual message.

delay Number

A time value in millisecond used to delay the message dispatching.

data Object

An object for custom data.

Author:

Members

data :Object

An object for custom data.

delay :Number

A time value in millisecond used to delay the message dispatching.

message :String

The actual message.

receiver :GameEntity

The receiver.

sender :GameEntity

The sender.

Methods

fromJSON(json) → {Telegram}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
Telegram -

A reference to this telegram.

resolveReferences(entities) → {Telegram}

Restores UUIDs with references to GameEntity objects.

Parameters:
Name Type Description
entities Map.<String, GameEntity>

Maps game entities to UUIDs.

Returns:
Telegram -

A reference to this telegram.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.