[9252] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Christoph Renner rennerc@ee.ethz.ch |
---|
| 13 | co-programmer: Patrick Boenzli boenzlip@orxonox.ethz.ch |
---|
| 14 | |
---|
| 15 | June 2006: finishing work on the network stream for pps presentation (rennerc@ee.ethz.ch) |
---|
| 16 | July 2006: some code rearangement and integration of the proxy server mechanism (boenzlip@ee.ethz.ch) |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | #define DEBUG_MODULE_NETWORK |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | #include "peer_info.h" |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | |
---|
[9357] | 29 | |
---|
[9252] | 30 | /** |
---|
| 31 | * constructor |
---|
| 32 | */ |
---|
| 33 | PeerInfo::PeerInfo() |
---|
| 34 | { |
---|
| 35 | this->clear(); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * clearint and initializing the peer info |
---|
| 41 | */ |
---|
| 42 | void PeerInfo::clear() |
---|
| 43 | { |
---|
| 44 | this->userId = 0; |
---|
| 45 | this->nodeType = NET_CLIENT; |
---|
| 46 | this->socket = NULL; |
---|
| 47 | this->handshake = NULL; |
---|
| 48 | this->lastAckedState = 0; |
---|
| 49 | this->lastRecvedState = 0; |
---|
| 50 | this->connectionMonitor = NULL; |
---|
[9308] | 51 | |
---|
[9334] | 52 | this->ip = IP(0,0); |
---|
[9252] | 53 | } |
---|
[9286] | 54 | |
---|
| 55 | |
---|
[9445] | 56 | const std::string& PeerInfo::getNodeTypeString() const |
---|
[9286] | 57 | { |
---|
[9445] | 58 | return PeerInfo::nodeTypeToString( this->nodeType ); |
---|
| 59 | // the above does the same, and is faster in it. (there is no case where node is uninit i hope!) |
---|
[9444] | 60 | /* |
---|
[9286] | 61 | switch( this->nodeType) |
---|
| 62 | { |
---|
| 63 | case NET_CLIENT: |
---|
| 64 | return std::string("client"); |
---|
[9303] | 65 | case NET_PROXY_SERVER_ACTIVE: |
---|
[9308] | 66 | return std::string("proxy server active"); |
---|
| 67 | case NET_PROXY_SERVER_PASSIVE: |
---|
| 68 | return std::string("proxy server passive"); |
---|
[9286] | 69 | case NET_MASTER_SERVER: |
---|
| 70 | return std::string("master server"); |
---|
| 71 | } |
---|
| 72 | |
---|
[9444] | 73 | return std::string("node is uninit");*/ |
---|
[9286] | 74 | } |
---|
[9444] | 75 | |
---|
[9445] | 76 | const std::string& PeerInfo::nodeTypeToString(unsigned int type) |
---|
| 77 | { |
---|
| 78 | return PeerInfo::nodeNames[type]; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
[9444] | 82 | const std::string PeerInfo::nodeNames[] = |
---|
| 83 | { |
---|
| 84 | |
---|
| 85 | "maser server", |
---|
| 86 | "proxy server active", |
---|
| 87 | "proxy server passive", |
---|
| 88 | "client", |
---|
| 89 | "node is not initialized" |
---|
| 90 | }; |
---|