Constructor
new Command(messageID, name, params)
Parameters:
Name | Type | Description |
---|---|---|
messageID |
number | Message ID unique identifying this message. |
name |
string | Command name. |
params |
Object.<string, ?> | Command parameters. |
- Source:
Methods
(static) fromPacket(data) → {Command}
Converts a data packet into Command
.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array.<number, number, ?, ?> | A four element array where the elements, in sequence, signifies message type, message ID, command name, and parameters. |
- Source:
Throws:
-
If the message type is not recognised.
- Type
- TypeError
Returns:
Representation of packet.
- Type
- Command
onresponse(resp)
Calls the error- or result handler associated with this command. This function can be replaced with a custom response handler.
Parameters:
Name | Type | Description |
---|---|---|
resp |
Response | The response to pass on to the result or error to the
|
- Source:
toPacket() → {Array}
Encodes the command to a packet.
- Source:
Returns:
Packet.
- Type
- Array