new MessageDispatcher()
Constructs a new message dispatcher.
Members
-
readonly delayedTelegrams :Array.<Telegram>
-
A list of delayed telegrams.
Methods
-
clear() → {MessageDispatcher}
-
Clears the internal state of this message dispatcher.
-
deliver(telegram) → {MessageDispatcher}
-
Delivers the message to the receiver.
Parameters:
Name Type Description telegram
Telegram The telegram to deliver.
-
dispatch(sender, receiver, message, delay, data) → {MessageDispatcher}
-
Receives the raw telegram data and decides how to dispatch the telegram (with or without delay).
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.
-
dispatchDelayedMessages(delta) → {MessageDispatcher}
-
Used to process delayed messages.
Parameters:
Name Type Description delta
Number The time delta.
-
fromJSON(json) → {MessageDispatcher}
-
Restores this instance from the given JSON object.
Parameters:
Name Type Description json
Object The JSON object.
-
resolveReferences(entities) → {MessageDispatcher}
-
Restores UUIDs with references to GameEntity objects.
Parameters:
Name Type Description entities
Map.<String, GameEntity> Maps game entities to UUIDs.
-
toJSON() → {Object}
-
Transforms this instance into a JSON object.
Returns:
Object -The JSON object.