Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/handshake.h @ 6115

Last change on this file since 6115 was 6115, checked in by rennerc, 18 years ago

handshake now sends NetworkGameManagerId

File size: 1.6 KB
Line 
1/*!
2 * @file network_stream.h
3 *  implementation of a network pipe
4 */
5
6#ifndef _HANDSHAKE
7#define _HANDSHAKE
8
9#include "base_object.h"
10#include "synchronizeable.h"
11
12#define _INITIAL_DATA "orxonox"
13#define _INITIAL_DATA_LENGTH 7
14
15#define _ORXONOX_VERSION "\x00\x00\x00\x01"
16#define _ORXONOX_VERSION_LENGTH 4
17
18typedef 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
31};
32
33class Handshake : public Synchronizeable
34{
35  public:
36    Handshake(bool server, int clientId = 0, int entityManagerId = 0);
37    inline bool       completed(){ return hasState( HS_COMPLETED ); }
38    inline bool       ok(){ return isOk; }
39    inline int        getHostId(){ return newHostId; }
40
41    inline void       doReject(){ setState(HS_DO_REJECT); }
42
43    virtual void      writeBytes(const byte* data, int length);
44    virtual int       readBytes(byte* data, int maxLength, int * reciever);
45    virtual void      writeDebug() const;
46    virtual void      readDebug() const;
47
48  private:
49    int               state;
50    int               clientId;
51    int               entityManagerId;
52    int               newHostId;
53    int               newEntityManagerId;
54    bool              isOk;
55
56    inline bool       hasState( int a ){ return (state & a) == a; }
57    inline void       setState( int a ){ state = state | a; }
58    inline void       unsetState( int a ){ state = state & (~a); }
59
60};
61
62
63#endif
Note: See TracBrowser for help on using the repository browser.