Changeset 9584 in orxonox.OLD for branches/proxy/src/lib
- Timestamp:
- Jul 28, 2006, 10:22:09 PM (18 years ago)
- Location:
- branches/proxy/src/lib/network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/monitor/network_monitor.h
r9583 r9584 76 76 77 77 inline const std::list<NetworkNode*>& getNodeList() const { return this->nodeList; }; 78 inline PeerInfo* getPeerByUserId( int userId) { this->localNode->getPeerByUserId(userId); }78 inline PeerInfo* getPeerByUserId( int userId) { return this->localNode->getPeerByUserId(userId); } 79 79 80 80 void toggleGUI(); -
branches/proxy/src/lib/network/network_stream.cc
r9583 r9584 121 121 this->pInfo->lastAckedState = 0; 122 122 this->pInfo->lastRecvedState = 0; 123 this->pInfo->bLocal = true; 123 124 124 125 this->bRedirect = false; … … 200 201 this->peers[node].connectionMonitor = new ConnectionMonitor( NET_ID_MASTER_SERVER ); 201 202 this->peers[node].ip = this->peers[node].socket->getRemoteAddress(); 203 this->peers[node].bLocal = true; 202 204 } 203 205 … … 219 221 this->peers[proxyId].connectionMonitor = new ConnectionMonitor( proxyId ); 220 222 this->peers[proxyId].ip = this->peers[proxyId].socket->getRemoteAddress(); 223 this->peers[proxyId].bLocal = true; 221 224 } 222 225 … … 257 260 // fake the unique id 258 261 hs->setUniqueID( NET_UID_HANDSHAKE ); 259 assert( peers[userId].handshake == NULL ); 260 peers[userId].handshake = hs; 262 assert( this->peers[userId].handshake == NULL ); 263 this->peers[userId].handshake = hs; 264 this->peers[userId].bLocal = true; 261 265 262 266 // set the preferred nick name … … 495 499 { 496 500 // create new handshake and init its variables 497 peers[userId].handshake = new Handshake(this->pInfo->nodeType, userId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID()); 498 peers[userId].handshake->setUniqueID(userId); 499 500 peers[userId].connectionMonitor = new ConnectionMonitor( userId ); 501 peers[userId].userId = userId; 501 this->peers[userId].handshake = new Handshake(this->pInfo->nodeType, userId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID()); 502 this->peers[userId].handshake->setUniqueID(userId); 503 504 this->peers[userId].connectionMonitor = new ConnectionMonitor( userId ); 505 this->peers[userId].userId = userId; 506 this->peers[userId].bLocal = true; 502 507 503 508 PRINTF(0)("num sync: %d\n", synchronizeables.size()); … … 508 513 if( pi != NULL) 509 514 { 510 peers[userId].handshake->setProxy1Address( pi->ip);515 this->peers[userId].handshake->setProxy1Address( pi->ip); 511 516 } 512 517 pi = this->networkMonitor->getSecondChoiceProxy(); 513 518 if( pi != NULL) 514 peers[userId].handshake->setProxy2Address( pi->ip);519 this->peers[userId].handshake->setProxy2Address( pi->ip); 515 520 516 521 // check if the connecting client should reconnect to a proxy server 517 522 if( SharedNetworkData::getInstance()->isMasterServer()) 518 peers[userId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false);523 this->peers[userId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false); 519 524 520 525 // the connecting node of course is a client 521 peers[userId].ip =peers[userId].socket->getRemoteAddress();526 this->peers[userId].ip = this->peers[userId].socket->getRemoteAddress(); 522 527 } 523 528 -
branches/proxy/src/lib/network/peer_info.cc
r9545 r9584 49 49 this->lastRecvedState = 0; 50 50 this->connectionMonitor = NULL; 51 this->bLocal = false; 51 52 52 53 this->ip = IP(0,0); -
branches/proxy/src/lib/network/peer_info.h
r9494 r9584 30 30 static const std::string& nodeTypeToString(unsigned int type); 31 31 32 inline bool isLocal() { return this->bLocal; } 32 33 33 34 … … 44 45 int lastRecvedState; //!< last received state 45 46 47 bool bLocal; //!< true if this node is localy connected to this node 48 46 49 static const std::string nodeNames[]; 47 50 -
branches/proxy/src/lib/network/proxy/proxy_control.cc
r9583 r9584 18 18 19 19 20 #include "player.h"21 20 #include "state.h" 22 21 #include "shared_network_data.h" 23 22 #include "network_game_manager.h" 23 #include "ip.h" 24 #include "peer_info.h" 24 25 25 26 #include "converter.h" … … 77 78 /** 78 79 * signals new client connected to this local proxy 80 * 81 * byte 0 - 3 : userId 82 * byte 4 - 7 : ip address (IPaddress.host) 83 * 79 84 * @param userId userId of the new client 80 85 */ … … 90 95 // and the ip as an int 91 96 PeerInfo* pInfo = SharedNetworkData::getInstance()->getNetworkMonitor()->getPeerByUserId(userId); 92 assert( Converter::intToByteArray( userId, data, INTSIZE ) == INTSIZE ); 93 94 MessageManager::getInstance()->sendMessage( MSGID_PROXY_NEWCLIENT, data, INTSIZE, RT_SERVER, NET_UNASSIGNED, MP_HIGHBANDWIDTH ); 97 assert(pInfo != NULL); 98 assert( Converter::intToByteArray( pInfo->ip.host(), data + INTSIZE, INTSIZE ) == INTSIZE ); 99 100 MessageManager::getInstance()->sendMessage( MSGID_PROXY_NEWCLIENT, data, 2*INTSIZE, RT_SERVER, NET_UNASSIGNED, MP_HIGHBANDWIDTH ); 95 101 } 96 102 … … 118 124 int newClientId = 0; 119 125 assert( Converter::byteArrayToInt( data, &newClientId) == INTSIZE ); 126 // now read the ip address 127 int ipHost = 0; 128 assert( Converter::byteArrayToInt( data + INTSIZE, &ipHost) == INTSIZE ); 129 130 // register the new node at the network monitor 131 NetworkMonitor* netMon = SharedNetworkData::getInstance()->getNetworkMonitor(); 132 PeerInfo* pInfo = new PeerInfo(); 133 pInfo->bLocal = false; 134 pInfo->ip = IP(ipHost, 0); 135 pInfo->nodeType = NET_CLIENT; 136 netMon->addNode(pInfo); 120 137 121 138 PRINTF(0)("Got Signal: from %i new player arrived with userId: %i\n", senderId, newClientId);
Note: See TracChangeset
for help on using the changeset viewer.