Message class, stores message name and data. The one that is transportend.
SliceMessage constructor
const myMessage = new SliceMessage('message', {
variable1: 'value1',
variable2: 'value2',
variableN: 'valueN'
});
Name | Type | Description |
---|---|---|
name | string | Message name |
data | variable | Message data |
Converts SliceMessage message object to string.
const myMessage = SliceMessage.create('message', {
variable1: 'value1',
variable2: 'value2',
variableN: 'valueN'
});
const myMessageString = myMessage.toString();
// '{"name": "Message name","data": {"variable1": "value1","variable2": "value2","variableN": "valueN"}}'
Creates new SliceMessage with provided name
and data
.
const myMessage = SliceMessage.create('message', {
variable1: 'value1',
variable2: 'value2',
variableN: 'valueN'
});
Parses str
and creates new SliceMessage.
str
should be in JSON format, like:
{
"name": "Message name",
"data": {
"variable1": "value1",
"variable2": "value2",
"variableN": "valueN"
}
}
const myJSON = '{"name": "Message name","data": {"variable1": "value1","variable2": "value2","variableN": "valueN"}}';
const myMessage = SliceMessage.fromJSON(myJSON);