Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/handshake.h @ 6139

Last change on this file since 6139 was 6139, checked in by patrick, 18 years ago

trunk: merged branche network with trunk using command: svn merge -r5999:HEAD, conflicts resolved in favor of the trunk bla

File size: 1.7 KB
RevLine 
[6043]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 {
[6053]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,
[6090]25  HS_COMPLETED  = 0x00000040,
[6043]26
[6090]27  HS_DO_REJECT  = 0x00010000,
28  HS_WAS_REJECT = 0x00020000,
29
[6043]30  NUM_STATES
31};
32
33class Handshake : public Synchronizeable
34{
35  public:
[6116]36    Handshake(bool server, int clientId = 0, int networkGameManagerId = 0);
[6053]37    inline bool       completed(){ return hasState( HS_COMPLETED ); }
[6043]38    inline bool       ok(){ return isOk; }
39    inline int        getHostId(){ return newHostId; }
[6116]40    inline int        getNetworkGameManagerId(){ return newNetworkGameManagerId; }
[6043]41
[6090]42    inline void       doReject(){ setState(HS_DO_REJECT); }
43
[6043]44    virtual void      writeBytes(const byte* data, int length);
[6053]45    virtual int       readBytes(byte* data, int maxLength, int * reciever);
[6043]46    virtual void      writeDebug() const;
47    virtual void      readDebug() const;
48
49  private:
50    int               state;
51    int               clientId;
[6116]52    int               networkGameManagerId;
[6043]53    int               newHostId;
[6116]54    int               newNetworkGameManagerId;
[6043]55    bool              isOk;
56
[6053]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); }
60
[6043]61};
62
63
64#endif
Note: See TracBrowser for help on using the repository browser.