Changeset 5961
- Timestamp:
- Oct 16, 2009, 3:38:48 PM (15 years ago)
- Location:
- code/trunk/src/libraries/network
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/network/Client.cc
r5929 r5961 111 111 return true; 112 112 } 113 114 void Client::printRTT(){ 115 COUT(0) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl; 116 } 113 117 114 118 /** -
code/trunk/src/libraries/network/Client.h
r5929 r5961 72 72 virtual bool chat(const std::string& message); 73 73 virtual bool broadcast(const std::string& message) { return false; } 74 virtual void printRTT(); 74 75 75 76 void update(const Clock& time); -
code/trunk/src/libraries/network/ClientConnection.cc
r5929 r5961 146 146 this->connectionClosed(); 147 147 } 148 149 uint32_t ClientConnection::getRTT() 150 { 151 assert(server_); 152 return server_->roundTripTime; 153 } 148 154 149 155 } -
code/trunk/src/libraries/network/ClientConnection.h
r5929 r5961 55 55 protected: 56 56 virtual void connectionClosed()=0; 57 uint32_t getRTT(); 57 58 private: 58 59 virtual void addPeer(ENetEvent* event); -
code/trunk/src/libraries/network/ClientInformation.cc
r5781 r5961 42 42 #define WIN32_LEAN_AND_MEAN 43 43 #include <enet/enet.h> 44 #include "ClientConnectionListener.h" 44 45 45 46 namespace orxonox … … 66 67 if(this==head_) 67 68 head_=next(); 69 ClientConnectionListener::broadcastClientDisconnected( this->getID() ); 68 70 } 69 71 -
code/trunk/src/libraries/network/Host.cc
r5781 r5961 50 50 assert(instance_==0); 51 51 instance_=this; 52 this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" ); 53 CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ ); 52 54 } 53 55 … … 59 61 { 60 62 instance_=0; 63 if( this->printRTTCC_ ) 64 delete this->printRTTCC_; 61 65 } 62 66 -
code/trunk/src/libraries/network/Host.h
r5781 r5961 31 31 32 32 #include "NetworkPrereqs.h" 33 #include "core/CorePrereqs.h" 33 34 34 35 namespace orxonox { … … 79 80 static bool Broadcast(const std::string& message); 80 81 static bool incomingChat(const std::string& message, unsigned int playerID); 82 virtual void printRTT()=0; 81 83 private: 84 ConsoleCommand* printRTTCC_; 82 85 }; 83 86 -
code/trunk/src/libraries/network/Server.cc
r5929 r5961 164 164 * @brief: returns ping time to client in milliseconds 165 165 */ 166 unsigned int Server::get Ping(unsigned int clientID){166 unsigned int Server::getRTT(unsigned int clientID){ 167 167 assert(ClientInformation::findClient(clientID)); 168 168 return ClientInformation::findClient(clientID)->getRTT(); 169 } 170 171 void Server::printRTT() 172 { 173 for( ClientInformation* temp=ClientInformation::getBegin(); temp!=0; temp=temp->next() ) 174 COUT(0) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl; 169 175 } 170 176 … … 299 305 { 300 306 //ServerConnection::disconnectClient( client ); 301 ClientConnectionListener::broadcastClientDisconnected( client->getID() );307 //ClientConnectionListener::broadcastClientDisconnected( client->getID() ); //this is done in ClientInformation now 302 308 delete client; 303 309 } … … 343 349 GamestateManager::removeClient(client); 344 350 // inform all the listeners 345 ClientConnectionListener::broadcastClientDisconnected(client->getID());351 // ClientConnectionListener::broadcastClientDisconnected(client->getID()); // this is done in ClientInformation now 346 352 } 347 353 -
code/trunk/src/libraries/network/Server.h
r5929 r5961 57 57 bool queuePacket(ENetPacket *packet, int clientID); 58 58 void update(const Clock& time); 59 unsigned int getPing(unsigned int clientID); 59 unsigned int getRTT(unsigned int clientID); 60 virtual void printRTT(); 60 61 double getPacketLoss(unsigned int clientID); 61 62 protected:
Note: See TracChangeset
for help on using the changeset viewer.