Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7954 in orxonox.OLD for trunk/src/lib/network/handshake.h


Ignore:
Timestamp:
May 29, 2006, 3:28:41 PM (19 years ago)
Author:
patrick
Message:

trunk: merged the network branche back to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/handshake.h

    r6341 r7954  
    1010#include "synchronizeable.h"
    1111
    12 #define _INITIAL_DATA "orxonox"
    13 #define _INITIAL_DATA_LENGTH 7
     12#define _ORXONOX_ID 0xF91337A0
    1413
    15 #define _ORXONOX_VERSION "\x00\x00\x00\x01"
    16 #define _ORXONOX_VERSION_LENGTH 4
     14#define _ORXONOX_VERSION 1
    1715
    18 typedef enum HandshakeState {
    19   HS_SENT_INIT  = 0x00000001,
    20   HS_RECVD_INIT = 0x00000002,
    21   HS_SENT_VER   = 0x00000004,
    22   HS_RECVD_VER  = 0x00000008,
    23   HS_SENT_HID   = 0x00000010,
    24   HS_RECVD_HID  = 0x00000020,
    25   HS_COMPLETED  = 0x00000040,
    26 
    27   HS_DO_REJECT  = 0x00010000,
    28   HS_WAS_REJECT = 0x00020000,
    29 
    30   NUM_STATES
     16struct HandshakeState {
     17  int orxId;
     18  int version;
     19 
     20  int networkManagerId;
     21  int messageManagerId;
     22  int hostId;
     23 
     24  int completed;
     25  int canDel;
     26 
     27  int error;
     28 
     29  std::string errorString;
    3130};
    3231
     
    3433{
    3534  public:
    36     Handshake(bool server, int clientId = 0, int networkGameManagerId = 0);
    37     inline bool       completed(){ return hasState( HS_COMPLETED ); }
    38     inline bool       ok(){ return isOk; }
    39     inline int        getHostId(){ return newHostId; }
    40     inline int        getNetworkGameManagerId(){ return newNetworkGameManagerId; }
    41 
    42     inline void       doReject(){ setState(HS_DO_REJECT); }
    43 
    44     virtual int       writeBytes(const byte* data, int length, int sender);
    45     virtual int       readBytes(byte* data, int maxLength, int * reciever);
    46     virtual void      writeDebug() const;
    47     virtual void      readDebug() const;
     35    Handshake( bool server, int clientId = 0, int networkGameManagerId = 0, int messageManagerId = 0 );
     36    inline bool       completed(){ return localState.completed != 0 && remoteState.completed != 0; }
     37    inline bool       ok(){ return localState.error == 0 && remoteState.error == 0; }
     38    inline int        getHostId(){ return remoteState.hostId; }
     39    inline int        getNetworkGameManagerId(){ return remoteState.networkManagerId; }
     40    inline int        getMessageManagerId(){ return remoteState.messageManagerId; }
     41    inline void       doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; }
     42    inline bool       canDel(){ return localState.canDel == 1 && remoteState.canDel == 1; }
     43    inline bool       allowDel(){ return localState.canDel == 1; }
     44    inline void       del(){ localState.canDel = 1; }
     45   
     46    virtual void varChangeHandler( std::list<int> & id );
    4847
    4948  private:
    50     int               state;
    51     int               clientId;
    52     int               networkGameManagerId;
    53     int               newHostId;
    54     int               newNetworkGameManagerId;
    55     bool              isOk;
    56 
    57     inline bool       hasState( int a ){ return (state & a) == a; }
    58     inline void       setState( int a ){ state = state | a; }
    59     inline void       unsetState( int a ){ state = state & (~a); }
     49    HandshakeState localState;
     50    HandshakeState remoteState;
     51   
     52    int netManId_handler;
     53    int msgManId_handler;
     54    int hostId_handler;
     55    int completed_handler;
     56    int error_handler;
     57    int errorString_handler;
     58    int orxId_handler;
     59    int version_handler;
     60    int candel_id;
    6061
    6162};
Note: See TracChangeset for help on using the changeset viewer.