Changeset 1261 for code/branches/network3/src/network
- Timestamp:
- May 12, 2008, 11:44:01 PM (17 years ago)
- Location:
- code/branches/network3/src/network
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/network/ClientConnection.cc
r1253 r1261 112 112 if(server==NULL) 113 113 return false; 114 if( !packet){115 COUT( 4) << "Cl.con: addpacket: invalid packet" << std::endl;114 if(packet==NULL){ 115 COUT(3) << "Cl.con: addpacket: invalid packet" << std::endl; 116 116 return false; 117 117 } -
code/branches/network3/src/network/ClientConnection.h
r1245 r1261 53 53 #define NETWORK_PORT 55556 54 54 #define NETWORK_CLIENT_MAX_CONNECTIONS 5 55 #define NETWORK_CLIENT_TIMEOUT 10 55 #define NETWORK_CLIENT_TIMEOUT 100 56 56 #define NETWORK_SEND_WAIT 5 57 57 #define NETWORK_CLIENT_CHANNELS 2 -
code/branches/network3/src/network/ClientInformation.h
r1232 r1261 92 92 93 93 bool head; 94 unsigned short failures_; 94 95 95 96 private: -
code/branches/network3/src/network/ConnectionManager.cc
r1250 r1261 191 191 //std::cout << "received data" << std::endl; 192 192 COUT(5) << "Con.Man: receive event has occured" << std::endl; 193 processData(event); 193 // only add, if client has connected yet and not been disconnected 194 if(head_->findClient(&event->peer->address)) 195 processData(event); 194 196 break; 195 197 case ENET_EVENT_TYPE_DISCONNECT: … … 354 356 } 355 357 358 bool ConnectionManager::removeShip(ClientInformation *client){ 359 int id=client->getShipID(); 360 orxonox::Iterator<orxonox::SpaceShip> it; 361 for(it = orxonox::ObjectList<orxonox::SpaceShip>::start(); it; ++it){ 362 if(it->objectID!=id) 363 continue; 364 delete *it; 365 } 366 return true; 367 } 368 356 369 bool ConnectionManager::sendWelcome(int clientID, int shipID, bool allowed){ 357 370 addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID); 358 371 sendPackets(); 359 372 return true; 373 } 374 375 void ConnectionManager::disconnectClient(ClientInformation *client){ 376 enet_peer_disconnect(client->getPeer(), 0); 377 removeShip(client); 360 378 } 361 379 -
code/branches/network3/src/network/ConnectionManager.h
r1245 r1261 86 86 bool sendPackets(); 87 87 bool createClient(int clientID); 88 void disconnectClient(ClientInformation *client); 88 89 89 90 private: … … 99 100 ENetPeer *getClientPeer(int clientID); 100 101 bool createShip(ClientInformation *client); 102 bool removeShip(ClientInformation *client); 101 103 bool sendWelcome(int clientID, int shipID, bool allowed); 102 104 bool addFakeConnectRequest(ENetEvent *ev); -
code/branches/network3/src/network/GameStateManager.cc
r1253 r1261 449 449 return true; // TODO: change this 450 450 } 451 452 void GameStateManager::removeClient(ClientInformation* client){ 453 gameStateUsed[client->getGamestateID()]--; 454 head_->removeClient(client->getID()); 455 } 451 456 452 457 } -
code/branches/network3/src/network/GameStateManager.h
r1232 r1261 76 76 bool pushGameState(GameStateCompressed *gs, int clientID); 77 77 void ackGameState(int clientID, int gamestateID); 78 void removeClient(ClientInformation *client); 78 79 private: 79 80 void cleanup(); // "garbage handler" -
code/branches/network3/src/network/Server.cc
r1253 r1261 53 53 namespace network 54 54 { 55 56 57 #define MAX_FAILURES 20; 58 59 55 60 /** 56 61 * Constructor for default values (bindaddress is set to ENET_HOST_ANY … … 205 210 } 206 211 //std::cout << "adding gamestate" << std::endl; 207 if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) ) 208 COUT(4) << "Server: packet with client id (cid): " << cid << " not sended" << std::endl; 212 if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) ){ 213 COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->failures_ << std::endl; 214 temp->failures_++; 215 if(temp->failures_ > 20 ) 216 disconnectClient(temp); 209 217 //std::cout << "added gamestate" << std::endl; 218 } 210 219 added=true; 211 220 temp=temp->next(); … … 240 249 if(!gamestates->pushGameState(data, clientID)) 241 250 COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl; 242 } 243 251 else 252 clients->findClient(clientID)->failures_=0; 253 } 254 255 void Server::disconnectClient(int clientID){ 256 ClientInformation *client = clients->findClient(clientID); 257 disconnectClient(client); 258 } 259 void Server::disconnectClient( ClientInformation *client){ 260 connection->disconnectClient(client); 261 gamestates->removeClient(client); 262 } 263 244 264 } -
code/branches/network3/src/network/Server.h
r1245 r1261 71 71 void updateGamestate(); 72 72 private: 73 void disconnectClient(int clientID); 74 void disconnectClient( ClientInformation *client); 73 75 bool sendGameState(); 74 76 void processAck( ack *data, int clientID);
Note: See TracChangeset
for help on using the changeset viewer.