new Message(type, content, destinations)
Creates an instance of Message
.
Parameters:
Name | Type | Description |
---|---|---|
type |
olympe.dc.Message.MessageType | Type of the message. |
content |
Object | string | The content of the message. |
destinations |
Array.<string> | The destinations for the message. |
Members
-
<static> MessageType :number
Methods
-
getContent()
-
Gets the content of the message.
Returns:
The content.
- Type
- Object | string
-
getContext()
-
Return the context associated to this message
Returns:
-
getDestinations()
-
Gets the destinations of the message.
Returns:
The destinations.
- Type
- Array.<string>
-
getType()
-
Gets the type of the message.
Returns:
The type.
-
onResponse(callback)
-
Register a
ResponseCallback
to be called when a response to this message is received.Parameters:
Name Type Description callback
olympe.dc.Message.ValidationCallback The function to call.
Returns:
this
Message
.- Type
- olympe.dc.Message
-
setContext(context)
-
Override the context associated to that message
Parameters:
Name Type Description context
olympe.df.ExecutionContext Returns:
this
- Type
- olympe.dc.Message
-
toString()
-
Returns:
- Type
- string
-
validate( [error])
-
Validate or not the message and triggers the response callback if specified for this message.
Parameters:
Name Type Argument Default Description error
Error <optional>
<nullable>
null The error, or
null
for success.
Type Definitions
-
MessageHandler(source, content)
-
Function to call when we receive a message of a specific type.
Parameters:
Name Type Description source
string the source id of the message
content
* the message content
-
ValidationCallback(error)
-
Function to be called when a response to a request is available. If an error occurred, it will be passed as an argument.
Parameters:
Name Type Argument Description error
Error <nullable>
The error or
null
for no error.