Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9258 in orxonox.OLD


Ignore:
Timestamp:
Jul 12, 2006, 5:37:58 PM (18 years ago)
Author:
patrick
Message:

working up the handshake

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/handshake.h

    r9235 r9258  
    1717  int orxId;
    1818  int version;
    19  
     19
    2020  int networkManagerId;
    2121  int messageManagerId;
    2222  int hostId;
    23  
     23
    2424  int completed;
    2525  int canDel;
    26  
     26
    2727  int error;
    28  
     28
    2929  std::string errorString;
    30  
     30
    3131  //additional data
    3232  std::string preferedNickName;
     
    3535class Handshake : public Synchronizeable
    3636{
     37
    3738  public:
    3839    Handshake( bool server, int clientId = 0, int networkGameManagerId = 0, int messageManagerId = 0 );
    39     inline bool       completed(){ return localState.completed != 0 && remoteState.completed != 0; }
    40     inline bool       ok(){ return localState.error == 0 && remoteState.error == 0; }
    41     inline int        getHostId(){ return remoteState.hostId; }
    42     inline int        getNetworkGameManagerId(){ return remoteState.networkManagerId; }
    43     inline int        getMessageManagerId(){ return remoteState.messageManagerId; }
    44     inline void       doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; }
    45     inline bool       canDel(){ return localState.canDel == 1 && remoteState.canDel == 1; }
    46     inline bool       allowDel(){ return localState.canDel == 1; }
    47     inline void       del(){ localState.canDel = 1; }
    48    
    49     inline void       setPreferedNickName( const std::string & nick ){ localState.preferedNickName = nick; }
     40
     41
     42    /** @returns true if the handshake is completed */
     43    inline bool completed(){ return localState.completed != 0 && remoteState.completed != 0; }
     44    /** @returns true if no error has occured until now */
     45    inline bool ok(){ return localState.error == 0 && remoteState.error == 0; }
     46    /** @returns the host id of the remote host */
     47    inline int  getHostId(){ return remoteState.hostId; }
     48    /** @returns the unique id of the network game manager*/
     49    inline int  getNetworkGameManagerId(){ return remoteState.networkManagerId; }
     50    /** @returns the unique id of the message manager */
     51    inline int  getMessageManagerId(){ return remoteState.messageManagerId; }
     52    /** stops the handshake and reject the other side with @param reason: string describing the reason */
     53    inline void doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; }
     54    /** @returns true if the handshake is finished and the instances can be deleted */
     55    inline bool canDel(){ return localState.canDel == 1 && remoteState.canDel == 1; }
     56    /** @returns true if the local state can be removed*/
     57    inline bool allowDel(){ return localState.canDel == 1; }
     58    /** marks the handshake to be deleted */
     59    inline void del(){ localState.canDel = 1; }
     60
     61    /** sets @param nick the prefereded nick name */
     62    inline void setPreferedNickName( const std::string & nick ){ localState.preferedNickName = nick; }
     63    /** @returns the prefered nick name */
    5064    inline std::string getPreferedNickName(){ return remoteState.preferedNickName; }
    51    
     65
    5266    virtual void varChangeHandler( std::list<int> & id );
    5367
     
    5569    HandshakeState localState;
    5670    HandshakeState remoteState;
    57    
     71
    5872    int netManId_handler;
    5973    int msgManId_handler;
Note: See TracChangeset for help on using the changeset viewer.