Changes between Version 2 and Version 3 of code/howto/Synchronisable
- Timestamp:
- Sep 25, 2008, 9:26:33 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/howto/Synchronisable
v2 v3 6 6 See also [wiki:network/Synchronisable] for more information. 7 7 == Basic steps == 8 1. {{{ #include "network/Synchronisable.h" }}} 9 2. make sure your class inherits from Synchronisable: 8 1. Include the appropriate header file: 9 {{{ 10 #include "network/Synchronisable.h" 11 }}} 12 2. Make sure your class inherits from Synchronisable: 10 13 {{{ 11 14 class XYZ : public network::Synchronisable { ... }; 12 15 }}} 13 3. create the function void registerAllVariables() and call REGISTERDATA or REGISTERSTRING functions in order to register these variables for synchronisation:16 3. Create the function void registerAllVariables() and call REGISTERDATA or REGISTERSTRING functions in order to register these variables for synchronisation: 14 17 {{{ 15 18 void XYZ::registerAllVariables(){ … … 18 21 } 19 22 }}} 20 4. make sure registerAllVariables() gets called in the constructor:23 4. Make sure registerAllVariables() gets called in the constructor: 21 24 {{{ 22 25 XYZ::XYZ(){ … … 25 28 } 26 29 }}} 27 5. implement the create() function and put all the code that needs some synchronisable variables to be set inside it:30 5. Implement the create() function and put all the code that needs some synchronisable variables to be set inside it: 28 31 {{{ 29 32 bool XYZ::create(){ … … 33 36 == Multidirectional synchronisation == 34 37 If you want to have a variable synchronised back to the server, follow these steps (additional to/instead of the above): 35 1. register the variable with REGISTERDATA_WITHDIR:38 1. Register the variable with REGISTERDATA_WITHDIR: 36 39 {{{ 37 40 void XYZ::registerAllVariables(){