Changeset 9625 in orxonox.OLD for branches/proxy/src/lib
- Timestamp:
- Jul 30, 2006, 11:19:24 PM (18 years ago)
- Location:
- branches/proxy/src/lib
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/coord/p_node.cc
r9623 r9625 54 54 parent->addChild(this); 55 55 56 this->relCoordinate_handle = this->registerVarId( new SynchronizeableVector( &relCoordinate, &relCoordinate_write, "coordinate" ) );57 this->relDirection_handle = this->registerVarId( new SynchronizeableQuaternion( &relDirection, &relDirection_write, "direction" ) );56 this->relCoordinate_handle = this->registerVarId( new SynchronizeableVector( &relCoordinate, &relCoordinate_write, "coordinate", PERMISSION_SERVER ) ); 57 this->relDirection_handle = this->registerVarId( new SynchronizeableQuaternion( &relDirection, &relDirection_write, "direction", PERMISSION_SERVER ) ); 58 58 } 59 59 -
branches/proxy/src/lib/network/README.NETWORK
r9597 r9625 1 2 1 3 2 4 … … 8 10 WORKING_STACK: 9 11 ============== 10 - it works to connecto to a master server which is connected to a proxy itself 11 12 - removed compiler warnings in some modules 13 - totaly rework of the permission system 14 - introduced a new PERMISSION layer: PERMISSION_SERVER which gives the nearest server the authority to handle 12 15 13 16 -
branches/proxy/src/lib/network/monitor/network_monitor.cc
r9589 r9625 10 10 11 11 ### File Specific: 12 main-programmer: Patrick Boenzli 12 main-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch) 13 13 */ 14 14 … … 49 49 this->networkStream = networkStream; 50 50 this->playerNumber = 0; 51 this->connectionNumber = 0; 51 52 // create the localnode, init it and add it to the nodes list 52 53 this->localNode = new NetworkNode( this->networkStream->getPeerInfo()); … … 69 70 peer->userId = -1; 70 71 71 NetworkNode* node = new NetworkNode(peer);72 this->addNode( node);73 72 this->addActiveProxyServer( this->localNode, peer); 74 73 } … … 141 140 return; 142 141 142 PRINTF(0)("^^^^^^^^^^^^^^^^^^^^^^^^^^ adding node: %i with type: %s\n\n", pInfo->userId, pInfo->getNodeTypeString().c_str()); 143 143 144 if( pInfo->isClient()) 144 this->localNode->addClient(pInfo); 145 { 146 this->localNode->addClient(new NetworkNode(pInfo)); 147 } 145 148 else if( pInfo->isProxyServerActive()) 146 149 { 147 this->localNode->addActiveProxyServer(pInfo); 148 // create a new node, since a proxy can connect clients again 149 NetworkNode* node = new NetworkNode(pInfo); 150 this->nodeList.push_back(node); 150 this->localNode->addActiveProxyServer(new NetworkNode(pInfo)); 151 } 152 else if( pInfo->isProxyServerActivePassive()) 153 { 154 this->localNode->addPassiveProxyServer(new NetworkNode(pInfo)); 151 155 } 152 156 else if( pInfo->isMasterServer()) 153 157 { 154 this->localNode->addMasterServer(pInfo); 155 } 158 this->localNode->addMasterServer(new NetworkNode(pInfo)); 159 } 160 else 161 assert(false); 156 162 } 157 163 … … 168 174 169 175 if( pInfo->isClient()) 170 node->addClient( pInfo);176 node->addClient(new NetworkNode(pInfo)); 171 177 else if( pInfo->isProxyServerActive()) 172 node->addActiveProxyServer( pInfo);178 node->addActiveProxyServer(new NetworkNode(pInfo)); 173 179 else if( pInfo->isMasterServer()) 174 node->addMasterServer( pInfo);180 node->addMasterServer(new NetworkNode(pInfo)); 175 181 } 176 182 … … 198 204 199 205 if( pInfo->isClient()) 200 node->removeClient(pInfo );206 node->removeClient(pInfo->userId); 201 207 else if( pInfo->isProxyServerActive()) 202 node->removeActiveProxyServer(pInfo );208 node->removeActiveProxyServer(pInfo->userId); 203 209 else if( pInfo->isMasterServer()) 204 node->removeMasterServer(pInfo );210 node->removeMasterServer(pInfo->userId); 205 211 } 206 212 … … 253 259 for(; it != this->nodeList.end(); it++) 254 260 { 261 PRINTF(0)("comparing %i to %i\n", (*it)->getPeerInfo()->userId, userId); 255 262 if( (*it)->getPeerInfo()->userId == userId) 256 263 return (*it); … … 308 315 for(; it != this->nodeList.end(); it++) 309 316 { 310 (*it)->debug( 0);317 (*it)->debug(1); 311 318 } 312 319 -
branches/proxy/src/lib/network/monitor/network_monitor.h
r9601 r9625 42 42 43 43 /** adds to @param node a network node @param pInfo a new client */ 44 inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient( pInfo); }44 inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(new NetworkNode(pInfo)); } 45 45 /** adds to @param node a network node @param pInfo a new proxy server */ 46 inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer( pInfo); }46 inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(new NetworkNode(pInfo)); } 47 47 /** adds to @param node a network node @param pInfo a new proxy server */ 48 inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer( pInfo); }48 inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer(new NetworkNode(pInfo)); } 49 49 /** adds to @param node a network node @param pInfo a new master server*/ 50 inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer( pInfo); }50 inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(new NetworkNode(pInfo)); } 51 51 52 52 void removeNode(PeerInfo* pInfo); 53 53 void removeNode(NetworkNode* node, PeerInfo* pInfo); 54 54 55 inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); }56 inline void removeActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeActiveProxyServer(pInfo); }57 inline void removePassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removePassiveProxyServer(pInfo); }58 inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); }55 inline void removeClient(NetworkNode* node, int userId) { node->removeClient(userId); } 56 inline void removeActiveProxyServer(NetworkNode* node, int userId) { node->removeActiveProxyServer(userId); } 57 inline void removePassiveProxyServer(NetworkNode* node, int userId) { node->removePassiveProxyServer(userId); } 58 inline void removeMasterServer(NetworkNode* node, int userId) { node->removeMasterServer(userId); } 59 59 60 60 PeerInfo* getFirstChoiceProxy() const; … … 64 64 65 65 /** @returns the active proxy server list of the localnode */ 66 inline std::list< PeerInfo*> getActiveProxyServer() const { return this->localNode->getActiveProxyServer(); }66 inline std::list<NetworkNode*> getActiveProxyServer() const { return this->localNode->getActiveProxyServer(); } 67 67 68 68 /* slots admin and info interface */ -
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 -
branches/proxy/src/lib/network/monitor/network_node.h
r9583 r9625 22 22 23 23 24 void addClient( PeerInfo* node);25 void addActiveProxyServer( PeerInfo* node);26 void addPassiveProxyServer( PeerInfo* node);27 void addMasterServer( PeerInfo* node);24 void addClient(NetworkNode* node); 25 void addActiveProxyServer(NetworkNode* node); 26 void addPassiveProxyServer(NetworkNode* node); 27 void addMasterServer(NetworkNode* node); 28 28 29 void removeClient(PeerInfo* node); 30 void removeActiveProxyServer(PeerInfo* node); 31 void removePassiveProxyServer(PeerInfo* node); 32 void removeMasterServer(PeerInfo* node); 29 void removeClient(NetworkNode* node); 30 void removeActiveProxyServer(NetworkNode* node); 31 void removePassiveProxyServer(NetworkNode* node); 32 void removeMasterServer(NetworkNode* node); 33 34 void removeClient(int userId); 35 void removeActiveProxyServer(int userId); 36 void removePassiveProxyServer(int userId); 37 void removeMasterServer(int userId); 38 33 39 34 40 PeerInfo* getClient(int index) const; … … 38 44 39 45 /** @returns the master server list */ 40 inline std::list< PeerInfo*> getMasterServer() const { return this->masterServerList; }46 inline std::list<NetworkNode*> getMasterServer() const { return this->masterServerList; } 41 47 /** @returns the active proxy server list */ 42 inline std::list< PeerInfo*> getActiveProxyServer() const { return this->activeProxyServerList; }48 inline std::list<NetworkNode*> getActiveProxyServer() const { return this->activeProxyServerList; } 43 49 /** @returns the passive proxy server list */ 44 inline std::list< PeerInfo*> getPassiveProxyServer() const { return this->passiveProxyServerList; }50 inline std::list<NetworkNode*> getPassiveProxyServer() const { return this->passiveProxyServerList; } 45 51 /** @returns the client list */ 46 inline std::list< PeerInfo*> getClient() const { return this->clientList; }52 inline std::list<NetworkNode*> getClient() const { return this->clientList; } 47 53 48 54 PeerInfo* getPeerByUserId( int userId); … … 64 70 65 71 /* network nodes directly connected to this node */ 66 std::list< PeerInfo*> clientList; //!< list of all clients in the network67 std::list< PeerInfo*> activeProxyServerList; //!< list of all proxy servers in the network68 std::list< PeerInfo*> passiveProxyServerList; //!< list of all proxy servers in the network69 std::list< PeerInfo*> masterServerList; //!< list of all master servers in the network (should be 1!! :D)72 std::list<NetworkNode*> clientList; //!< list of all clients in the network 73 std::list<NetworkNode*> activeProxyServerList; //!< list of all proxy servers in the network 74 std::list<NetworkNode*> passiveProxyServerList; //!< list of all proxy servers in the network 75 std::list<NetworkNode*> masterServerList; //!< list of all master servers in the network (should be 1!! :D) 70 76 71 77 }; -
branches/proxy/src/lib/network/nettypes.h
r9494 r9625 10 10 PERMISSION_MASTER_SERVER = 1, 11 11 PERMISSION_PROXY_SERVER = 2, 12 PERMISSION_OWNER = 4, 13 PERMISSION_ALL = 8 12 PERMISSION_SERVER = 4, 13 PERMISSION_OWNER = 8, 14 PERMISSION_ALL = 16 14 15 }; 15 16 -
branches/proxy/src/lib/network/network_game_manager.cc
r9561 r9625 68 68 69 69 this->gameState = 0; 70 registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) );70 registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState", PERMISSION_MASTER_SERVER ) ); 71 71 } 72 72 -
branches/proxy/src/lib/network/network_manager.cc
r9604 r9625 142 142 143 143 // then start the server 144 this->networkStream->createServer( port, port + 1, port + 2);144 // this->networkStream->createServer( port, port + 1, port + 2); 145 145 146 146 // and to the other proxy servers also, this would be very nice if its works -
branches/proxy/src/lib/network/network_stream.cc
r9605 r9625 81 81 // init the shared network data 82 82 SharedNetworkData::getInstance()->setHostID(NET_ID_MASTER_SERVER); 83 this->pInfo->userId = NET_ID_MASTER_SERVER; 84 this->pInfo->nodeType = NET_MASTER_SERVER; 85 83 86 break; 84 87 case NET_PROXY_SERVER_ACTIVE: 85 88 // init the shared network data 86 89 SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01); 90 this->pInfo->nodeType = NET_PROXY_SERVER_ACTIVE; 91 87 92 break; 88 93 case NET_PROXY_SERVER_PASSIVE: 89 94 // init the shared network data 90 95 SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01); 96 this->pInfo->nodeType = NET_PROXY_SERVER_PASSIVE; 97 91 98 break; 92 99 case NET_CLIENT: 93 100 SharedNetworkData::getInstance()->setHostID(NET_ID_UNASSIGNED); 101 this->pInfo->nodeType = NET_CLIENT; 94 102 break; 95 103 } … … 526 534 it++; 527 535 } 528 529 530 536 } 531 537 … … 685 691 // it->second.ip = it->second.socket->getRemoteAddress(); 686 692 687 //it->second.nodeType = it->second.handshake->getRemoteNodeType();693 it->second.nodeType = it->second.handshake->getRemoteNodeType(); 688 694 // it->second.ip = it->second.socket->getRemoteAddress(); 689 695 // add the new server to the nodes list (it can be a NET_MASTER_SERVER or NET_PROXY_SERVER) -
branches/proxy/src/lib/network/player_stats.cc
r9575 r9625 65 65 this->oldNickName = "Player"; 66 66 67 userId_handle = registerVarId( new SynchronizeableInt( &assignedUserId, &assignedUserId, "userId" ) );68 teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) );69 preferedTeamId_handle = registerVarId( new SynchronizeableInt( &preferedTeamId, &preferedTeamId, "preferedUserId" ) );70 score_handle = registerVarId( new SynchronizeableInt( &score, &score, "score" ) );71 playableClassId_handle = registerVarId( new SynchronizeableInt( &playableClassId, &playableClassId, "playableClassId" ) );72 playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId" ) );73 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );74 nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName" ) );67 userId_handle = registerVarId( new SynchronizeableInt( &assignedUserId, &assignedUserId, "userId", PERMISSION_MASTER_SERVER ) ); 68 teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId", PERMISSION_MASTER_SERVER ) ); 69 preferedTeamId_handle = registerVarId( new SynchronizeableInt( &preferedTeamId, &preferedTeamId, "preferedUserId", PERMISSION_MASTER_SERVER ) ); 70 score_handle = registerVarId( new SynchronizeableInt( &score, &score, "score", PERMISSION_MASTER_SERVER ) ); 71 playableClassId_handle = registerVarId( new SynchronizeableInt( &playableClassId, &playableClassId, "playableClassId", PERMISSION_MASTER_SERVER) ); 72 playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId", PERMISSION_MASTER_SERVER ) ); 73 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName", PERMISSION_MASTER_SERVER ) ); 74 nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName", PERMISSION_MASTER_SERVER ) ); 75 75 76 76 MessageManager::getInstance()->registerMessageHandler( MSGID_CHANGENICKNAME, changeNickHandler, NULL ); -
branches/proxy/src/lib/network/proxy/proxy_control.cc
r9603 r9625 39 39 40 40 41 // SHELL_COMMAND(forceReconnect, ProxyControl, forceReconnectionShell); 42 SHELL_COMMAND(bla, ProxyControl, forceReconnectionShellThumb); 43 41 SHELL_COMMAND(forceReconnect, ProxyControl, forceReconnectionShell); 44 42 45 43 /** … … 250 248 void ProxyControl::forceReconnectionShell(int userId, int serverId) 251 249 { 250 PRINTF(0)("shell reconnectoin command: %i to %i\n", userId, serverId); 251 252 252 this->forceReconnection(userId, serverId); 253 253 } … … 264 264 if( serverInfo == NULL) 265 265 { 266 PRINTF(0)("There is no node with userId %i registered in this network. Check the uid again\n");267 return; 268 } 269 else if( serverInfo->is MasterServer() || serverInfo->isProxyServerActive())270 { 271 PRINTF(0)("You can't connec to to a client (userId %i)\n", serverId);266 PRINTF(0)("There is no server with userId %i registered in this network. Check the uid again\n", serverId); 267 return; 268 } 269 else if( serverInfo->isClient()) 270 { 271 PRINTF(0)("You can't connec to to a client (userId %i)\n", serverId); 272 272 return; 273 273 } … … 306 306 if( pInfo == NULL) 307 307 { 308 PRINTF(0)("There is no node with userId %i registered in this network. Check the uid again\n");308 PRINTF(0)("There is no client with userId %i registered in this network. Check the uid again\n", userId); 309 309 return; 310 310 } … … 316 316 assert( Converter::intToByteArray( newAddress.host(), data + 2 * INTSIZE, INTSIZE ) == INTSIZE ); 317 317 318 PRINTF(0)("Sending reconnection command to: %i\n", userId); 318 319 MessageManager::getInstance()->sendMessage( MSGID_PROXY_COMMAND, data, 3*INTSIZE, RT_ALL_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH ); 319 320 } -
branches/proxy/src/lib/network/proxy/proxy_control.h
r9603 r9625 18 18 typedef enum proxyCommand { 19 19 PXY_RECONNECT = 0, //!< forces a reconnection of the node 20 21 PXY_WEAKUP, //!< signal to weakup a sleeping proxy server (not impl. yet) 22 PXY_SLEEP, //!< signal to sleep and disconnect clients 20 23 21 24 PXY_NUMBER -
branches/proxy/src/lib/network/synchronizeable.cc
r9606 r9625 55 55 /* make sure loadClassId is first synced var because this is read by networkStream */ 56 56 assert( syncVarList.size() == 0 ); 57 mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" 58 59 this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) );60 this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) );57 mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId", PERMISSION_MASTER_SERVER) ); 58 59 this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner", PERMISSION_MASTER_SERVER ) ); 60 this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName", PERMISSION_MASTER_SERVER ) ); 61 61 } 62 62 … … 127 127 { 128 128 //make sure this user has his history 129 if ( sentStates.size() <= userId )129 if ( (int)sentStates.size() <= userId ) 130 130 sentStates.resize( userId+1 ); 131 131 … … 207 207 for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ ) 208 208 { 209 209 210 // DATA PERMISSIONS 210 211 // check if this synchronizeable has the permissions to write the data 211 212 213 #if 0 212 214 // MASTER_SERVER |====> * 213 215 if( SharedNetworkData::getInstance()->isMasterServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER )) … … 243 245 hasPermission = true; 244 246 247 else 248 hasPermission = false; 249 #endif 250 251 //////////////////////////////// 252 // Data SENDING Permissions 253 //////////////////////////////// 254 255 // Permission OWNER accept if: 256 // I am the owner 257 if( (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID()) 258 hasPermission = true; 259 // reciever != owner && owner is local 260 else if( (*it)->checkPermission( PERMISSION_OWNER ) && userId != this->owner && 261 (SharedNetworkData::getInstance()->isUserLocal(this->owner) || this->owner == SharedNetworkData::getInstance()->getHostID())) 262 hasPermission = true; 263 264 265 // Permission MASTER_SERVER accept if: 266 // im MASTER_SERVER 267 else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isMasterServer()) 268 hasPermission = true; 269 // im PROXY_SERVER && reciever == CLIENT 270 else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isProxyServerActive() && 271 SharedNetworkData::getInstance()->isUserClient( userId)) 272 hasPermission = true; 273 274 275 // Pemission SERVER accept if: 276 // i am server && reciever == CLIENT 277 else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() && 278 SharedNetworkData::getInstance()->isUserClient( userId)) 279 hasPermission = true; 280 // i am SERVER && reciever == SERVER && reciever != owner && ( owner is local || i am owner) 281 else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() && 282 userId != this->owner && 283 ( SharedNetworkData::getInstance()->isUserLocal( userId) || this->owner == SharedNetworkData::getInstance()->getHostID())) 284 hasPermission = true; 285 286 287 // Permission ALL accept if: 288 else if( (*it)->checkPermission( PERMISSION_ALL )) 289 hasPermission = true; 290 291 292 // or else refuse sending data 245 293 else 246 294 hasPermission = false; … … 308 356 { 309 357 //make sure this user has his history 310 if ( recvStates.size() <= userId )358 if ( (int)recvStates.size() <= userId ) 311 359 recvStates.resize( userId+1 ); 312 360 … … 367 415 368 416 369 // * <====| MASTER_SERVER 370 if( this->networkStream->isUserMasterServer( userId ) && (*it)->checkPermission( PERMISSION_MASTER_SERVER )) 371 hasPermission = true; 372 else if( this->networkStream->isUserMasterServer( userId ) && 373 this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER )) 374 hasPermission = true; 375 376 // * <====| PROXY_SERVER 377 else if( this->networkStream->isUserProxyServerActive( userId ) && 378 this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER )) 379 hasPermission = true; 380 // CLIENT <====| PROXY_SERVER 381 else if( this->networkStream->isUserProxyServerActive( userId ) && SharedNetworkData::getInstance()->isClient() 382 && (*it)->checkPermission( PERMISSION_MASTER_SERVER )) 383 hasPermission = true; 384 // MASTER_SERVER <====| PROXY_SERVER 385 else if( this->networkStream->isUserProxyServerActive( userId ) && SharedNetworkData::getInstance()->isMasterServer() && 386 !this->networkStream->isUserLocal( userId )) 387 hasPermission = true; 388 389 // * <====| OWNER 390 else if( this->owner == userId && (*it)->checkPermission( PERMISSION_OWNER )) 391 hasPermission = true; 392 393 // * <====| ALL 394 else if( (*it)->checkPermission( PERMISSION_ALL )) 395 hasPermission = true; 396 417 //////////////////////////////// 418 // Data RECIEVING Permissions 419 //////////////////////////////// 420 421 // i should never ever receive a state update from a synchronizeable, that belongs to me! If it does somethings wrong with the send rules 422 // assert( !((*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID())); 423 424 425 // Permission OWNER accept if: 426 // sender == owner 427 if( (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId) 428 hasPermission = true; 429 // sender == MASTER_SERVER 430 else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserMasterServer( userId)) 431 hasPermission = true; 432 // sender == PROXY_SERVER 433 else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserProxyServerActive( userId)) 434 hasPermission = true; 435 436 // Permission MASTER_SERVER accept if: 437 // sender == MASTER_SERVER 438 else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isUserMasterServer( userId)) 439 hasPermission = true; 440 // sender == PROXY_SERVER && im not MASTER_SERVER && im not PROXY_SERVER 441 else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isClient() && 442 SharedNetworkData::getInstance()->isUserProxyServerActive( userId)) 443 hasPermission = true; 444 445 // Permission SERVER accept if: 446 // sender == SERVER 447 else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isUserClient( userId) ) 448 hasPermission = true; 449 450 // Pemission ALL accept if: 451 else if( (*it)->checkPermission( PERMISSION_ALL )) 452 hasPermission = true; 453 454 // no rights to over-write local data 397 455 else 398 456 hasPermission = false; … … 466 524 void Synchronizeable::cleanUpUser( int userId ) 467 525 { 468 if ( recvStates.size() > userId )526 if ( (int)recvStates.size() > userId ) 469 527 { 470 528 for ( std::list<StateHistoryEntry*>::iterator it = recvStates[userId].begin(); it != recvStates[userId].end(); it++ ) … … 481 539 } 482 540 483 if ( sentStates.size() > userId )541 if ( (int)sentStates.size() > userId ) 484 542 { 485 543 … … 507 565 { 508 566 //make sure this user has his history 509 if ( recvStates.size() <= userId )567 if ( (int)recvStates.size() <= userId ) 510 568 recvStates.resize( userId+1 ); 511 569 … … 597 655 { 598 656 //make sure this user has his history 599 if ( sentStates.size() <= userId )657 if ( (int)sentStates.size() <= userId ) 600 658 sentStates.resize( userId+1 ); 601 659 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_bool.h
r9406 r9625 12 12 13 13 public: 14 SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );14 SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission, int priority = 0 ); 15 15 virtual ~SynchronizeableBool(); 16 16 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_float.h
r9406 r9625 13 13 14 14 public: 15 SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );15 SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission, int priority = 0 ); 16 16 virtual ~SynchronizeableFloat(); 17 17 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_int.h
r9406 r9625 13 13 14 14 public: 15 SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );15 SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission, int priority = 0 ); 16 16 virtual ~SynchronizeableInt(); 17 17 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.h
r9406 r9625 15 15 16 16 public: 17 SynchronizeableIP( IP *ptrIn, IP * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );17 SynchronizeableIP( IP *ptrIn, IP * ptrOut, std::string name, int permission, int priority = 0 ); 18 18 virtual ~SynchronizeableIP(); 19 19 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h
r9406 r9625 14 14 15 15 public: 16 SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );16 SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission, int priority = 0 ); 17 17 virtual ~SynchronizeableQuaternion(); 18 18 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_string.h
r9406 r9625 14 14 15 15 public: 16 SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );16 SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission, int priority = 0 ); 17 17 virtual ~SynchronizeableString(); 18 18 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_uint.h
r9406 r9625 13 13 14 14 public: 15 SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );15 SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission, int priority = 0 ); 16 16 virtual ~SynchronizeableUInt(); 17 17 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_var.h
r9494 r9625 15 15 16 16 public: 17 SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );17 SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission, int priority = 0 ); 18 18 virtual ~SynchronizeableVar(); 19 19 -
branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_vector.h
r9406 r9625 14 14 15 15 public: 16 SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );16 SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission, int priority = 0 ); 17 17 virtual ~SynchronizeableVector(); 18 18
Note: See TracChangeset
for help on using the changeset viewer.