models.ClientModel Class
This the top-level client model class that contains the local player, map contents, etc.
Constructor
models.ClientModel
(
-
playerID
Parameters:
-
playerID
IntegerThe id of the local player, extracted from the cookie
Item Index
Methods
Methods
initFromServer
(
-
success
This is called to fetch the game state from the server the very first time. It should: 1) fetch the game state JSON from the server, 2) update the client model with the returned data, 3) notify all client model listeners that the model has changed, and 4) invoke the success callback function with the object received from the server.
Parameters:
-
success
Function- A callback function that is called after the game state has been fetched from the server and the client model updated. This function is passed a single parameter which is the game state object received from the server.