Class MessageBuilder
Defined in: message-builder.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Class MessageBuilder
Create messages to send to the server in a simple way.
|
Method Attributes | Method Name and Description |
---|---|
createAction(name, data)
Create an action message, and stringify to JSON.
|
|
createAuthenticationData(username, valid)
Create a data message confirming the authentication.
|
|
Create a request message asking for the login of the client.
|
|
createData(method, object, object_data)
Create a data message, and stringify to JSON.
|
|
createMessage(type, data)
Create the basic structure of a message, and stringify to JSON.
|
|
createNewGameData(game)
|
|
createNewPlayerData(player)
|
|
createQuery(responseMethod, responseData)
Create a query message, and stringify to JSON.
|
|
createUpdateGameData(game)
|
|
createUpdatePlayerData(player)
|
|
createUpdateUnitData(unit)
|
Class Detail
MessageBuilder()
Class MessageBuilder
Create messages to send to the server in a simple way.
Author: Adrian Gaudebert - adrian@gaudebert.fr, Van-Duc Nguyen.
Author: Adrian Gaudebert - adrian@gaudebert.fr, Van-Duc Nguyen.
Method Detail
createAction(name, data)
Create an action message, and stringify to JSON.
- Parameters:
- name
- Name of the action.
- data
- Object containing data about this action.
- Returns:
- JSON message to send.
createAuthenticationData(username, valid)
Create a data message confirming the authentication.
- Parameters:
- username
- Login used to authenticate.
- valid
- Boolean to say if authentication is done or not.
- Returns:
- JSON message to send.
createAuthenticationQuery()
Create a request message asking for the login of the client.
- Returns:
- JSON message to send.
createData(method, object, object_data)
Create a data message, and stringify to JSON.
- Parameters:
- method
- What to do with data. Can be "new", "update" or "delete".
- object
- Name of the concerned object.
- object_data
- Object containing data about this object.
- Returns:
- JSON message to send.
createJoinAction()
createMessage(type, data)
Create the basic structure of a message, and stringify to JSON.
- Parameters:
- type
- Type of message. Can be "login", "query", "data" or "action".
- data
- Object containing data of the message.
- Returns:
- JSON message to send.
createNewGameData(game)
- Parameters:
- game
createNewPlayerData(player)
- Parameters:
- player
createQuery(responseMethod, responseData)
Create a query message, and stringify to JSON.
- Parameters:
- responseMethod
- Type of message we want to receive in response.
- responseData
- Object containing data about this query.
- Returns:
- JSON message to send.
createUpdateGameData(game)
- Parameters:
- game
createUpdatePlayerData(player)
- Parameters:
- player
createUpdateUnitData(unit)
- Parameters:
- unit