Changes between Version 4 and Version 5 of code/doc/network/Synchronisable
- Timestamp:
- Sep 29, 2008, 2:36:40 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/doc/network/Synchronisable
v4 v5 13 13 * network::direction::bidirectional (==0x3) sync in both directions 14 14 15 Every object and every registered variable ha vea syncdirection (default: toclient).15 Every object and every registered variable has a syncdirection (default: toclient). 16 16 17 17 In order to synchronise a variable in a class, these steps must be done: … … 63 63 64 64 === Synchronisation Direction === 65 As mentioned above, the default direction of the Synchronisation is toclient. If you want to change this, you need to register the variable with either REGISTERDATA_WITHDIR or REGISTERSTRING_WITHDIR (normally per-class, see below). Additionally you have to set the global syncdirection (per-object, see below) to directional or toclient (again: not recommended65 As mentioned above, the default direction of the Synchronisation is toclient. If you want to change this, you need to register the variable with either REGISTERDATA_WITHDIR or REGISTERSTRING_WITHDIR (normally per-class, see below). Additionally you have to set the global syncdirection (per-object, see below) to bidirectional or toclient (again: not recommended) 66 66 {{{ 67 67 int SomeClass::syncback; 68 REGISTERDATA_WITHDIR( i, network::direction::bidirectional); // put this inside registerAllVariables68 REGISTERDATA_WITHDIR(syncback, network::direction::bidirectional); // put this inside registerAllVariables 69 69 this->setObjectMode(network::direction::bidirectional); // put this wherever you want (it is possible to do this only for specific objects specified by objectID) 70 70 }}} … … 73 73 When synchronising an object the first time to a client (or server) the following steps occur: 74 74 * A new object gets created with the appropriate class 75 * by calling the constructor of the class alsoregisterAllVariables gets called (make sure this is in your constructor)76 * After construction of the object finished the data getupdated (all variables previously registered by registerAllVariables)75 * By calling the constructor of the class registerAllVariables gets called (make sure this is in your constructor) 76 * After construction of the object is finished the data gets updated (all variables previously registered by registerAllVariables) 77 77 * After that the create() function gets called. 78 78 79 Because we don't have the data at construction time, all functions that need member variables (with data from the server) must be called inside create(). See example class for details.79 Because we don't have the data at construction time, '''all functions that need member variables''' (with data from the server) '''must be called inside create()''' (instead of inside the constructor). See example class for details. 80 80 81 81 == Preconditions ==