Class Index | File Index

Classes


Class MessageBuilder


Defined in: message-builder.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Class MessageBuilder Create messages to send to the server in a simple way.
Method Summary
Method Attributes Method Name and Description
 
Create an action message: abandon.
 
createAction(name, data)
Create an action message, and stringify to JSON.
 
createAttackUnitAction(AttackerId, VictimId)
Create action message: attack unit.
 
createAuthenticationLogin(login, password)
Create a login message to authenticate on the server.
 
Create an action message: end turn.
 
Create an action message to join a game.
 
createLogin(login, data)
Create a login message, and stringify to JSON.
 
createMessage(type, data)
Create the basic structure of a message, and stringify to JSON.
 
createMoveUnitAction(unitId, to_X, to_Y)
Create action message: move unit.
 
createQuery(responseMethod, responseData)
Create a query message, and stringify to JSON.
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.
Method Detail
createAbandonAction()
Create an action message: abandon.
Returns:
JSON message to send.

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.

createAttackUnitAction(AttackerId, VictimId)
Create action message: attack unit.
Parameters:
AttackerId
Id of the unit which is attacker.
VictimId
Id of the unit which is attacked.
Returns:
JSON message to send.

createAuthenticationLogin(login, password)
Create a login message to authenticate on the server.
Parameters:
login
Login of the user.
password
Password of the user.
Returns:
JSON message to send.

createEndTurnAction()
Create an action message: end turn.
Returns:
JSON message to send.

createJoinGameAction(gameId)
Create an action message to join a game.
Parameters:
gameId
Identifier of the game to join.
Returns:
JSON message to send.

createLogin(login, data)
Create a login message, and stringify to JSON.
Parameters:
login
Username.
data
Object containing other login data.
Returns:
JSON message to send.

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.

createMoveUnitAction(unitId, to_X, to_Y)
Create action message: move unit.
Parameters:
unitId
Id of the unit which the player want to move.
to_X
Target Absciss.
to_Y
Target Ordinate.
Returns:
JSON message to send.

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.

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 21 2011 17:31:12 GMT+0100 (CET)