-
Notifications
You must be signed in to change notification settings - Fork 219
Messages
This article is a stub
The addition of new functionnalities to browser quest will most likely require that the server and the client exchange information. Beyond the websockets in themselves, we'll try to explain here how the server and the client exchange.
They do so by sending each other messages. Each messages is associated to a constant which allows the recipient to expect a certain data structuration, which in terms allows the listener to interpret the data sent to it.
The constants associated to the message types are centralized in shared/js/gametypes.js.
Once a new message type has been added to the constants, it needs to be specified further.
The formats of the messages that the server might receive are stored in server/js/format.js.
Messages exchanged take the form of an array of data each cell of which can be either a number 'n'
or a string 's'
. These descriptions are stored in an array (FormatChecker.formats[Types.Messages.*]
) when they are fixed. When a message can have various number of parameters, the testing is to be hard coded in check() (cf. the case of Types.Messages.WHO
).
The format are consistent with the send*
functions provided in client/js/gameclient.js. These send function provide an array with the type of message in the first cell and parameters in the next ones.