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
-
List of message types that can be sent to the router
Type:
- number
Properties:
Name Type Default Description ERRORnumber 1 KEEP_ALIVEnumber 2 GET_CONTEXTnumber 10 GET_CONTEXT_ERRORnumber 11 SUBSCRIPTION_CREATEnumber 20 SUBSCRIPTION_SUBSCRIBEnumber 21 SUBSCRIPTION_UPDATEnumber 22 SUBSCRIPTION_UNSUBSCRIBEnumber 23 GRAPHDEF_SUBSCRIPTIONnumber 24 GRAPHDEF_GETnumber 25 GRAPHDEF_UPDATEnumber 26 GRAPHDEF_UNSUBSCRIBEnumber 28 QUERY_EXECUTIONnumber 30 QUERY_SUBSCRIPTIONnumber 31 QUERY_UNSUBSCRIBEnumber 32 TRANSACTION_REQUESTnumber 40 TRANSACTION_REQUEST_HTTPnumber 41 BURST_TRANSACTIONnumber 45 BURST_TRANSACTION_ERRORnumber 46 FINALIZE_TRANSACTIONnumber 47 UPLOAD_FILEnumber 50 DOWNLOAD_FILEnumber 51 DELETE_FILEnumber 52 UNDO_TRANSACTIONnumber 60 REDO_TRANSACTIONnumber 61 GET_STACKnumber 62 GET_STACK_RESPONSEnumber 63 CLEAR_STACKnumber 64 BURST_TRANSACTION_DONEnumber 65 GENERIC_ACKnumber 90 DATA_NOTIFICATIONnumber 91 GRAPH_RESULTnumber 92 GRAPH_NOTIFICATIONnumber 93 LIST_NOTIFICATIONnumber 94 NOTIFICATION_DONEnumber 95 SUBSCRIPTION_DONEnumber 96 QUERY_RESULTnumber 97 QUERY_RESULT_UPDATEnumber 98
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
ResponseCallbackto be called when a response to this message is received.Parameters:
Name Type Description callbackolympe.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 contextolympe.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 errorError <optional>
<nullable>
null The error, or
nullfor success.
Type Definitions
-
MessageHandler(source, content)
-
Function to call when we receive a message of a specific type.
Parameters:
Name Type Description sourcestring 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 errorError <nullable>
The error or
nullfor no error.
Olympe SDK