27 | | The most important part of the Network API is the Synchronisable Class (see also [wiki:network/Synchronisable Synchronisable]): |
28 | | * This class provides the functionality for objects to get synchronised over the network: |
29 | | * REGISTERDATA/REGISTERSTRING: these functions register a variable (to the Network Engine) that needs synchronisation |
30 | | * setObjectMode: this function sets the direction of synchronisation (server->client / server<->client / server<-client) |
31 | | * Every class that needs synchronisation must fullfill some dependencies: |
32 | | * It must (public) inherit from Synchronisable |
33 | | * It must have a default constructor |
34 | | * All steps in object creation that need data (from the levelfile or the network) must be in the create() function |
35 | | * It must implement the following functions: |
36 | | * registerAllVariables: register all variables (currently only basic types and strings), that need synchronisation, to the network engine by calling REGISTERDATA and/or REGISTERSTRING |
37 | | * create: (as described above) |
38 | | * set appropriate synchronisation direction (default: server->client) by calling setObjectMode |
39 | | |
40 | | |
41 | | ''' Synchronisable functions:'''[[BR]] |
42 | | ''REGISTERDATA(varname)''[[BR]] |
43 | | Use this makro to synchronise a membervariable of a class (like position, velocity, ...). This makro sets the sync-direction of the variable to server->client |
44 | | {{{ |
45 | | int SomeClass::i; // membervariable i |
46 | | REGISTERDATA(i); |
47 | | }}} |
48 | | ''REGISTERDATA_WITHMODE(varname, mode)''[[BR]] |
49 | | Use this makro if you want to sync a variable using a different direction than the default. |
50 | | {{{ |
51 | | int SomeClass::i; //membervariable i |
52 | | REGISTERDATA_WITHMODE(i, network::direction::toclient); //same as REGISTERDATA(i) |
53 | | //or |
54 | | REGISTERDATA_WITHMODE(i, network::direction::toserver); //sync i only to the server (be carefull when using this) |
55 | | //or |
56 | | REGISTERDATA_WITHMODE(i, network::direction::bidirectional); //sync i in both directions |
57 | | }}} |
58 | | |
59 | | ''REGISTERSTRING(stringname)''[[BR]] |
60 | | same as REGISTERDATA but for strings |
61 | | |
62 | | ''REGISTERSTRING_WITHMODE(stringname, mode)''[[BR]] |
63 | | same as REGISTERDATA_WITHMODE but for strings |
64 | | |
65 | | ''setObjectMode''[[BR]] |
66 | | this sets the sync direction of the whole object (default: server->client). |
67 | | '''Note:''' if you don't call setObjectMode with a value other than network::direction::toclient then the variables will only be synchronised to the client (if at all) |
| 27 | The [wiki:network/Synchronisable Synchronisable] class is a base class of all Objects that need to be synchronised (e.g. SpaceShip, Model, Projectile, etc.). It is the interface between the ObjectHierarchy and the Network Engine. For more information about this go [wiki:network/Synchronisable here]. |