Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 5 and Version 6 of code/doc/Network


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

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/Network

    v5 v6  
    2525== External API ==
    2626=== Synchronisable ===
    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)
     27The [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].
    6828=== Host ===
     29The [wiki:network/Host Host] class is the Base class of the Server and Client classes. It provides some static functions:
     30 * network::Host::running(): return true, if a server or client is running
     31 * network::Host::getPlayerID(): returns the player id of a client (this is only a temporary hack until we have a PlayerManager)
     32 * network::Host::getShipID(): return the objectID of the players ship (also a temporary hack)
     33 * network::Host::isServer(): return true/false (whether we are in server/client mode)
     34 * other functions (not really meant to be used outside the network engine)