Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

trunk: merged the network branche back to trunk.

File size: 1.7 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 _ORXONOX_ID 0xF91337A0
13
14#define _ORXONOX_VERSION 1
15
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;
30};
31
32class Handshake : public Synchronizeable
33{
34  public:
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 );
47
48  private:
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;
61
62};
63
64
65#endif
Note: See TracBrowser for help on using the repository browser.