Last change
on this file since 9164 was
9116,
checked in by rennerc, 18 years ago
|
player joins game with last chosen nickname
|
File size:
2.0 KB
|
Rev | Line | |
---|
[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 | |
---|
[7954] | 12 | #define _ORXONOX_ID 0xF91337A0 |
---|
[6043] | 13 | |
---|
[7954] | 14 | #define _ORXONOX_VERSION 1 |
---|
[6043] | 15 | |
---|
[7954] | 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; |
---|
[9116] | 30 | |
---|
| 31 | //additional data |
---|
| 32 | std::string preferedNickName; |
---|
[6043] | 33 | }; |
---|
| 34 | |
---|
| 35 | class Handshake : public Synchronizeable |
---|
| 36 | { |
---|
| 37 | public: |
---|
[7954] | 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 | |
---|
[9116] | 49 | inline void setPreferedNickName( const std::string & nick ){ localState.preferedNickName = nick; } |
---|
| 50 | inline std::string getPreferedNickName(){ return remoteState.preferedNickName; } |
---|
| 51 | |
---|
[7954] | 52 | virtual void varChangeHandler( std::list<int> & id ); |
---|
[6043] | 53 | |
---|
| 54 | private: |
---|
[7954] | 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; |
---|
[6043] | 67 | |
---|
| 68 | }; |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.