Changeset 9625 in orxonox.OLD for branches/proxy/src/lib/network/monitor/network_node.cc
- Timestamp:
- Jul 30, 2006, 11:19:24 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/monitor/network_node.cc
r9583 r9625 39 39 * adds a client 40 40 */ 41 void NetworkNode::addClient( PeerInfo* node)41 void NetworkNode::addClient(NetworkNode* node) 42 42 { 43 43 this->clientList.push_back(node); … … 49 49 * adds a proxy server 50 50 */ 51 void NetworkNode::addActiveProxyServer( PeerInfo* node)51 void NetworkNode::addActiveProxyServer(NetworkNode* node) 52 52 { 53 53 this->activeProxyServerList.push_back(node); … … 58 58 * adds a proxy server 59 59 */ 60 void NetworkNode::addPassiveProxyServer( PeerInfo* node)60 void NetworkNode::addPassiveProxyServer(NetworkNode* node) 61 61 { 62 62 this->passiveProxyServerList.push_back(node); … … 66 66 * adds a master server 67 67 */ 68 void NetworkNode::addMasterServer( PeerInfo* node)68 void NetworkNode::addMasterServer(NetworkNode* node) 69 69 { 70 70 this->masterServerList.push_back(node); … … 75 75 * removes a client 76 76 */ 77 void NetworkNode::removeClient( PeerInfo* node)78 { 79 std::list< PeerInfo*>::iterator it = this->clientList.begin();77 void NetworkNode::removeClient(NetworkNode* node) 78 { 79 std::list<NetworkNode*>::iterator it = this->clientList.begin(); 80 80 for(; it != this->clientList.end(); it++) 81 81 { … … 94 94 * removes a proxy server 95 95 */ 96 void NetworkNode::removeActiveProxyServer( PeerInfo* node)97 { 98 std::list< PeerInfo*>::iterator it = this->activeProxyServerList.begin();96 void NetworkNode::removeActiveProxyServer(NetworkNode* node) 97 { 98 std::list<NetworkNode*>::iterator it = this->activeProxyServerList.begin(); 99 99 for(; it != this->activeProxyServerList.end(); it++) 100 100 { … … 113 113 * removes a proxy server 114 114 */ 115 void NetworkNode::removePassiveProxyServer( PeerInfo* node)116 { 117 std::list< PeerInfo*>::iterator it = this->passiveProxyServerList.begin();115 void NetworkNode::removePassiveProxyServer(NetworkNode* node) 116 { 117 std::list<NetworkNode*>::iterator it = this->passiveProxyServerList.begin(); 118 118 for(; it != this->passiveProxyServerList.end(); it++) 119 119 { … … 131 131 * removes a master server 132 132 */ 133 void NetworkNode::removeMasterServer( PeerInfo* node)134 { 135 std::list< PeerInfo*>::iterator it = this->masterServerList.begin();133 void NetworkNode::removeMasterServer(NetworkNode* node) 134 { 135 std::list<NetworkNode*>::iterator it = this->masterServerList.begin(); 136 136 for(; it != this->masterServerList.end(); it++) 137 137 { … … 146 146 PRINTF(2)("Could not remove client from the list, very strange..."); 147 147 } 148 149 150 151 152 /** 153 * removes a client 154 */ 155 void NetworkNode::removeClient(int userId) 156 { 157 std::list<NetworkNode*>::iterator it = this->clientList.begin(); 158 for(; it != this->clientList.end(); it++) 159 { 160 if( (*it)->getPeerInfo()->userId == userId) 161 { 162 this->clientList.erase(it); 163 this->playerNumber--; 164 return; 165 } 166 } 167 168 PRINTF(2)("Could not remove client from the list, very strange..."); 169 } 170 171 /** 172 * removes a proxy server 173 */ 174 void NetworkNode::removeActiveProxyServer(int userId) 175 { 176 std::list<NetworkNode*>::iterator it = this->activeProxyServerList.begin(); 177 for(; it != this->activeProxyServerList.end(); it++) 178 { 179 if( (*it)->getPeerInfo()->userId == userId) 180 { 181 this->activeProxyServerList.erase(it); 182 this->playerNumber--; 183 return; 184 } 185 } 186 187 PRINTF(2)("Could not remove proxy server from the list, very strange..."); 188 } 189 190 /** 191 * removes a proxy server 192 */ 193 void NetworkNode::removePassiveProxyServer(int userId) 194 { 195 std::list<NetworkNode*>::iterator it = this->passiveProxyServerList.begin(); 196 for(; it != this->passiveProxyServerList.end(); it++) 197 { 198 if( (*it)->getPeerInfo()->userId == userId) 199 { 200 this->passiveProxyServerList.erase(it); 201 return; 202 } 203 } 204 205 PRINTF(2)("Could not remove proxy server from the list, very strange..."); 206 } 207 208 /** 209 * removes a master server 210 */ 211 void NetworkNode::removeMasterServer(int userId) 212 { 213 std::list<NetworkNode*>::iterator it = this->masterServerList.begin(); 214 for(; it != this->masterServerList.end(); it++) 215 { 216 if( (*it)->getPeerInfo()->userId == userId) 217 { 218 this->masterServerList.erase(it); 219 this->playerNumber--; 220 return; 221 } 222 } 223 224 PRINTF(2)("Could not remove client from the list, very strange..."); 225 } 226 227 148 228 149 229 … … 157 237 { 158 238 // look through the master server lists 159 std::list< PeerInfo*>::const_iterator it = this->masterServerList.begin();239 std::list<NetworkNode*>::const_iterator it = this->masterServerList.begin(); 160 240 for( ;it != this->masterServerList.end(); it++) 161 241 { 162 if( (*it)-> userId == userId)163 return (*it) ;242 if( (*it)->getPeerInfo()->userId == userId) 243 return (*it)->getPeerInfo(); 164 244 } 165 245 … … 168 248 for( ; it != this->activeProxyServerList.end(); it++) 169 249 { 170 if( (*it)-> userId == userId)171 return (*it) ;250 if( (*it)->getPeerInfo()->userId == userId) 251 return (*it)->getPeerInfo(); 172 252 } 173 253 … … 176 256 for( ; it != this->passiveProxyServerList.end(); it++) 177 257 { 178 if( (*it)-> userId == userId)179 return (*it) ;258 if( (*it)->getPeerInfo()->userId == userId) 259 return (*it)->getPeerInfo(); 180 260 } 181 261 … … 184 264 for( ; it != this->clientList.end(); it++) 185 265 { 186 if( (*it)-> userId == userId)187 return (*it) ;266 if( (*it)->getPeerInfo()->userId == userId) 267 return (*it)->getPeerInfo(); 188 268 } 189 269 … … 201 281 return NULL; 202 282 203 std::list< PeerInfo*>::const_iterator it = this->clientList.begin();283 std::list<NetworkNode*>::const_iterator it = this->clientList.begin(); 204 284 for(int i = 0; it != this->clientList.end(); it++, i++) 205 285 { 206 286 if( i == index) 207 return (*it) ;287 return (*it)->getPeerInfo(); 208 288 } 209 289 … … 221 301 return NULL; 222 302 223 std::list< PeerInfo*>::const_iterator it = this->activeProxyServerList.begin();303 std::list<NetworkNode*>::const_iterator it = this->activeProxyServerList.begin(); 224 304 for(int i = 0; it != this->activeProxyServerList.end(); it++, i++) 225 305 { 226 306 if( i == index) 227 return (*it) ;307 return (*it)->getPeerInfo(); 228 308 } 229 309 … … 241 321 return NULL; 242 322 243 std::list< PeerInfo*>::const_iterator it = this->passiveProxyServerList.begin();323 std::list<NetworkNode*>::const_iterator it = this->passiveProxyServerList.begin(); 244 324 for(int i = 0; it != this->passiveProxyServerList.end(); it++, i++) 245 325 { 246 326 if( i == index) 247 return (*it) ;327 return (*it)->getPeerInfo(); 248 328 } 249 329 … … 261 341 return NULL; 262 342 263 std::list< PeerInfo*>::const_iterator it = this->masterServerList.begin();343 std::list<NetworkNode*>::const_iterator it = this->masterServerList.begin(); 264 344 for(int i = 0; it != this->masterServerList.end(); it++, i++) 265 345 { 266 346 if( i == index) 267 return (*it) ;347 return (*it)->getPeerInfo(); 268 348 } 269 349 … … 278 358 void NetworkNode::debug(int depth) const 279 359 { 280 PRINT(0)(" = %s\n", this->peerInfo->getNodeTypeString().c_str()); 281 282 PRINT(0)(" master servers: %i\n", this->masterServerList.size()); 283 std::list<PeerInfo*>::const_iterator it = this->masterServerList.begin(); 284 for(; it != this->masterServerList.end(); it++) 285 { 286 IP* ip = &(*it)->ip; 287 PRINT(0)(" - ms, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str()); 288 } 289 290 PRINT(0)(" proxy servers active: %i\n", this->activeProxyServerList.size()); 291 it = this->activeProxyServerList.begin(); 292 for(; it != this->activeProxyServerList.end(); it++) 293 { 294 IP* ip = &(*it)->ip; 295 PRINT(0)(" - ps-a, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str()); 296 } 297 298 PRINT(0)(" proxy servers passive: %i\n", this->passiveProxyServerList.size()); 299 it = this->passiveProxyServerList.begin(); 300 for(; it != this->passiveProxyServerList.end(); it++) 301 { 302 IP* ip = &(*it)->ip; 303 PRINT(0)(" - ps-p, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str()); 304 } 305 306 PRINT(0)(" clients: %i\n", this->clientList.size()); 307 it = this->clientList.begin(); 308 for(; it != this->clientList.end(); it++) 309 { 310 IP* ip = &(*it)->ip; 311 PRINT(0)(" - client, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str()); 312 } 313 } 314 360 char indent[depth +1]; 361 for( int i = 0; i < depth; i++) { indent[i] = ' '; } 362 indent[depth] = '\0'; 363 364 PRINT(0)("%s + %s, with ip: %s\n", indent, this->peerInfo->getNodeTypeString().c_str(), this->peerInfo->ip.ipString().c_str()); 365 std::list<NetworkNode*>::const_iterator it; 366 if( !this->masterServerList.empty()) 367 { 368 // PRINT(0)("%s + master servers: %i\n", indent, this->masterServerList.size()); 369 it = this->masterServerList.begin(); 370 371 for(; it != this->masterServerList.end(); it++) 372 { 373 // IP* ip = &(*it)->getPeerInfo()->ip; 374 // PRINT(0)("%s - ms, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str()); 375 (*it)->debug(depth+1); 376 } 377 } 378 379 if( !this->activeProxyServerList.empty()) 380 { 381 // PRINT(0)("%s + proxy servers active: %i\n", indent, this->activeProxyServerList.size()); 382 it = this->activeProxyServerList.begin(); 383 384 for(; it != this->activeProxyServerList.end(); it++) 385 { 386 // IP* ip = &(*it)->getPeerInfo()->ip; 387 // PRINT(0)("%s - ps-a, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str()); 388 (*it)->debug(depth+1); 389 } 390 } 391 392 393 if( !this->passiveProxyServerList.empty()) 394 { 395 // PRINT(0)("%s proxy servers passive: %i\n", indent, this->passiveProxyServerList.size()); 396 it = this->passiveProxyServerList.begin(); 397 398 for(; it != this->passiveProxyServerList.end(); it++) 399 { 400 // IP* ip = &(*it)->getPeerInfo()->ip; 401 // PRINT(0)("%s - ps-p, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str()); 402 (*it)->debug(depth+1); 403 } 404 } 405 406 if( !this->clientList.empty()) 407 { 408 // PRINT(0)("%s clients: %i\n", indent, this->clientList.size()); 409 it = this->clientList.begin(); 410 411 for(; it != this->clientList.end(); it++) 412 { 413 // IP* ip = &(*it)->getPeerInfo()->ip; 414 // PRINT(0)("%s - client, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str()); 415 (*it)->debug(depth+1); 416 } 417 } 418 } 419
Note: See TracChangeset
for help on using the changeset viewer.