Last change
on this file since 9165 was
9116,
checked in by rennerc, 18 years ago
|
player joins game with last chosen nickname
|
File size:
2.0 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 | |
---|
16 | struct 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 | //additional data |
---|
32 | std::string preferedNickName; |
---|
33 | }; |
---|
34 | |
---|
35 | class Handshake : public Synchronizeable |
---|
36 | { |
---|
37 | public: |
---|
38 | 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; } |
---|
50 | inline std::string getPreferedNickName(){ return remoteState.preferedNickName; } |
---|
51 | |
---|
52 | virtual void varChangeHandler( std::list<int> & id ); |
---|
53 | |
---|
54 | private: |
---|
55 | HandshakeState localState; |
---|
56 | HandshakeState remoteState; |
---|
57 | |
---|
58 | int netManId_handler; |
---|
59 | int msgManId_handler; |
---|
60 | int hostId_handler; |
---|
61 | int completed_handler; |
---|
62 | int error_handler; |
---|
63 | int errorString_handler; |
---|
64 | int orxId_handler; |
---|
65 | int version_handler; |
---|
66 | int candel_id; |
---|
67 | |
---|
68 | }; |
---|
69 | |
---|
70 | |
---|
71 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.