Sending a message

A message that isn't sent as a response to another message can contain the following attributes:

The type of message, typically the name of the function or command to execute. This should normally be short with no embedded spaces.
A string that identifies this instance of the message, which can be anything the client selects. The server always reflects it back. By convention, if the id is omitted, the server shouldn't provide a response. Therefore, the presence or absence of the id can be used to as a mechanism to request a response. Typically, the id is simply a sequence number represented as a string, although it might be anything. There is no requirement that the id be unique.
Other data (for example, parameters) associated with the message. This attribute is optional. The dat attribute is frequently JSON encoded because there is often a need to encode more than a simple string.