- Timestamp:
- Jul 25, 2006, 10:34:28 AM (18 years ago)
- Location:
- branches/proxy/src/lib/network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/README.NETWORK
r9449 r9450 29 29 NET_MAX_CONNECTION Last client 30 30 31 The proxy server ids are assigned as stated in the data/trunk/config/network_settings.conf, the first proxy server in the list gets the id NET_ID_PROXY_01 and so on. 32 31 33 32 34 -
branches/proxy/src/lib/network/netdefs.h
r9449 r9450 62 62 }; 63 63 64 //!< the type of the u serid (special number never used elsewhere)64 //!< the type of the unique id (special number never used elsewhere) 65 65 typedef enum { 66 66 NET_UID_UNASSIGNED = -1, 67 68 NET_UID_HANDSHAKE = 0, 69 67 70 68 71 NET_UID_NUMBER … … 70 73 71 74 72 //!< the id of the node75 //!< the network id list 73 76 typedef enum nodeId { 74 77 NET_ID_UNASSIGNED =-1, -
branches/proxy/src/lib/network/network_manager.cc
r9449 r9450 133 133 this->networkStream->createServer( port); 134 134 // and connect to the master server for synchronization 135 int userId =this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr().ipString(), 9999);135 this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr().ipString(), 9999); 136 136 // and to the other proxy servers also, this would be very nice if its works 137 137 -
branches/proxy/src/lib/network/network_stream.cc
r9449 r9450 182 182 * @param port: the port number 183 183 */ 184 intNetworkStream::connectToMasterServer(std::string host, int port)185 { 186 int node = this->peers.size();184 void NetworkStream::connectToMasterServer(std::string host, int port) 185 { 186 int node = NET_ID_MASTER_SERVER; 187 187 // this create the new node in the peers map 188 188 this->peers[node].socket = new UdpSocket( host, port ); 189 this->peers[node].userId = 0;189 this->peers[node].userId = NET_ID_MASTER_SERVER; 190 190 191 191 this->peers[node].nodeType = NET_MASTER_SERVER; 192 this->peers[node].connectionMonitor = new ConnectionMonitor( 0);192 this->peers[node].connectionMonitor = new ConnectionMonitor( NET_ID_MASTER_SERVER ); 193 193 this->peers[node].ip = this->peers[node].socket->getRemoteAddress(); 194 195 return node;196 194 } 197 195 … … 202 200 * @param port: the port number 203 201 */ 204 int NetworkStream::connectToProxyServer(std::string host, int port) 205 { 206 int node = this->peers.size(); 207 PRINTF(0)("connect to proxy %s, this is node %i\n", host.c_str(), node); 208 209 // this creates the new node in the peers map 210 this->peers[node].socket = new UdpSocket( host, port ); 211 this->peers[node].userId = 0; 212 213 this->peers[node].nodeType = NET_PROXY_SERVER_ACTIVE; 214 this->peers[node].connectionMonitor = new ConnectionMonitor( 0 ); 215 this->peers[node].ip = this->peers[node].socket->getRemoteAddress(); 216 217 return node; 202 void NetworkStream::connectToProxyServer(int proxyId,std::string host, int port) 203 { 204 PRINTF(0)("connect to proxy %s, this is proxyId %i\n", host.c_str(), proxyId); 205 206 // this creates the new proxyId in the peers map 207 this->peers[proxyId].socket = new UdpSocket( host, port ); 208 this->peers[proxyId].userId = proxyId; 209 210 this->peers[proxyId].nodeType = NET_PROXY_SERVER_ACTIVE; 211 this->peers[proxyId].connectionMonitor = new ConnectionMonitor( proxyId ); 212 this->peers[proxyId].ip = this->peers[proxyId].socket->getRemoteAddress(); 218 213 } 219 214 … … 250 245 { 251 246 Handshake* hs = new Handshake(this->pInfo->nodeType); 252 hs->setUniqueID( 0 ); 247 // fake the unique id 248 hs->setUniqueID( NET_UID_HANDSHAKE ); 253 249 assert( peers[userId].handshake == NULL ); 254 250 peers[userId].handshake = hs; … … 327 323 { 328 324 // check if the connection is ok else terminate and remove 329 if ( !peers.empty() && peers[0].socket && ( !peers[0].socket->isOk() || peers[0].connectionMonitor->hasTimedOut() ) ) 330 { 331 this->handleDisconnect( 0); 325 #warning make this more modular: every proxy/master server connection should be watched for termination 326 if ( !peers.empty() && peers[NET_ID_MASTER_SERVER].socket && 327 ( !peers[NET_ID_MASTER_SERVER].socket->isOk() || 328 peers[NET_ID_MASTER_SERVER].connectionMonitor->hasTimedOut() ) ) 329 { 330 this->handleDisconnect( NET_ID_MASTER_SERVER); 332 331 PRINTF(1)("lost connection to server\n"); 333 332 } … … 335 334 if( this->bRedirect) 336 335 { 337 this->handleReconnect( 0);336 this->handleReconnect( NET_ID_MASTER_SERVER); 338 337 } 339 338 } … … 625 624 // disconnect from the current server and reconnect to proxy server 626 625 this->handleDisconnect( userId); 627 this->connectToProxyServer( proxyIP.ipString(), 9999);626 this->connectToProxyServer(NET_ID_PROXY_SERVER_01, proxyIP.ipString(), 9999); 628 627 #warning the ports are not yet integrated correctly in the ip class 629 628 … … 707 706 708 707 // do not include synchronizeables with uninit id and syncs that don't want to be synchronized 709 if ( !sync.beSynchronized() || sync.getUniqueID() < 0)708 if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED ) 710 709 continue; 711 710 … … 769 768 Synchronizeable & sync = **it; 770 769 771 if ( !sync.beSynchronized() || sync.getUniqueID() < 0 ) 770 // again exclude all unwanted syncs 771 if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED) 772 772 continue; 773 773 … … 969 969 Synchronizeable & sync = **it; 970 970 971 if ( !sync.beSynchronized() || sync.getUniqueID() < 0)971 if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED ) 972 972 continue; 973 973 -
branches/proxy/src/lib/network/network_stream.h
r9449 r9450 41 41 void init(); 42 42 43 intconnectToMasterServer(std::string host, int port);44 int connectToProxyServer(std::string host, int port);43 void connectToMasterServer(std::string host, int port); 44 void connectToProxyServer(int proxyId, std::string host, int port); 45 45 void createServer(int port); 46 46 47 47 void createNetworkGameManager(); 48 void startHandshake(int userId = 0);48 void startHandshake(int userId = NET_ID_MASTER_SERVER); 49 49 50 50 /* synchronizeable interface */
Note: See TracChangeset
for help on using the changeset viewer.