Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/network/Synchronisable


Ignore:
Timestamp:
Sep 13, 2008, 2:35:08 PM (16 years ago)
Author:
scheusso
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/network/Synchronisable

    v1 v1  
     1= Synchronisable =
     2The most important part of the Network API is the Synchronisable Class (see also [wiki:network/Synchronisable Synchronisable]):
     3 * This class provides the functionality for objects to get synchronised over the network:
     4   * REGISTERDATA/REGISTERSTRING: these functions register a variable (to the Network Engine) that needs synchronisation
     5   * setObjectMode: this function sets the direction of synchronisation (server->client / server<->client / server<-client)
     6 * Every class that needs synchronisation must fullfill some dependencies:
     7   * It must (public) inherit from Synchronisable
     8   * It must have a default constructor
     9   * All steps in object creation that need data (from the levelfile or the network) must be in the create() function
     10   * It must implement the following functions:
     11     * registerAllVariables: register all variables (currently only basic types and strings), that need synchronisation, to the network engine by calling REGISTERDATA and/or REGISTERSTRING
     12     * create: (as described above)
     13     * set appropriate synchronisation direction (default: server->client) by calling setObjectMode
     14
     15
     16''' Synchronisable functions:'''[[BR]]
     17''REGISTERDATA(varname)''[[BR]]
     18Use this makro to synchronise a membervariable of a class (like position, velocity, ...). This makro sets the sync-direction of the variable to server->client
     19{{{
     20int SomeClass::i; // membervariable i
     21REGISTERDATA(i);
     22}}}
     23''REGISTERDATA_WITHMODE(varname, mode)''[[BR]]
     24Use this makro if you want to sync a variable using a different direction than the default.
     25{{{
     26int SomeClass::i; //membervariable i
     27REGISTERDATA_WITHMODE(i, network::direction::toclient); //same as REGISTERDATA(i)
     28//or
     29REGISTERDATA_WITHMODE(i, network::direction::toserver); //sync i only to the server (be carefull when using this)
     30//or
     31REGISTERDATA_WITHMODE(i, network::direction::bidirectional); //sync i in both directions
     32}}}
     33
     34''REGISTERSTRING(stringname)''[[BR]]
     35same as REGISTERDATA but for strings
     36
     37''REGISTERSTRING_WITHMODE(stringname, mode)''[[BR]]
     38same as REGISTERDATA_WITHMODE but for strings
     39
     40''setObjectMode''[[BR]]
     41this sets the sync direction of the whole object (default: server->client).
     42'''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)