Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5961 for code


Ignore:
Timestamp:
Oct 16, 2009, 3:38:48 PM (15 years ago)
Author:
scheusso
Message:

new ConsoleCommand: printRTT: prints the round trip time to (the server / all clients)
small change in ClientDisconnection handling (only internal)

Location:
code/trunk/src/libraries/network
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/network/Client.cc

    r5929 r5961  
    111111    return true;
    112112  }
     113 
     114  void Client::printRTT(){
     115    COUT(0) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;
     116  }
    113117
    114118  /**
  • code/trunk/src/libraries/network/Client.h

    r5929 r5961  
    7272    virtual bool chat(const std::string& message);
    7373    virtual bool broadcast(const std::string& message) { return false; }
     74    virtual void printRTT();
    7475
    7576    void update(const Clock& time);
  • code/trunk/src/libraries/network/ClientConnection.cc

    r5929 r5961  
    146146    this->connectionClosed();
    147147  }
     148 
     149  uint32_t ClientConnection::getRTT()
     150  {
     151    assert(server_);
     152    return server_->roundTripTime;
     153  }
    148154
    149155}
  • code/trunk/src/libraries/network/ClientConnection.h

    r5929 r5961  
    5555  protected:
    5656    virtual void connectionClosed()=0;
     57    uint32_t getRTT();
    5758  private:
    5859    virtual void addPeer(ENetEvent* event);
  • code/trunk/src/libraries/network/ClientInformation.cc

    r5781 r5961  
    4242#define WIN32_LEAN_AND_MEAN
    4343#include <enet/enet.h>
     44#include "ClientConnectionListener.h"
    4445
    4546namespace orxonox
     
    6667    if(this==head_)
    6768      head_=next();
     69    ClientConnectionListener::broadcastClientDisconnected( this->getID() );
    6870  }
    6971
  • code/trunk/src/libraries/network/Host.cc

    r5781 r5961  
    5050  assert(instance_==0);
    5151  instance_=this;
     52  this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" );
     53  CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ );
    5254}
    5355
     
    5961{
    6062  instance_=0;
     63  if( this->printRTTCC_ )
     64    delete this->printRTTCC_;
    6165}
    6266
  • code/trunk/src/libraries/network/Host.h

    r5781 r5961  
    3131
    3232#include "NetworkPrereqs.h"
     33#include "core/CorePrereqs.h"
    3334
    3435namespace orxonox {
     
    7980    static bool Broadcast(const std::string& message);
    8081    static bool incomingChat(const std::string& message, unsigned int playerID);
     82    virtual void printRTT()=0;
    8183  private:
     84    ConsoleCommand* printRTTCC_;
    8285};
    8386
  • code/trunk/src/libraries/network/Server.cc

    r5929 r5961  
    164164   * @brief: returns ping time to client in milliseconds
    165165   */
    166   unsigned int Server::getPing(unsigned int clientID){
     166  unsigned int Server::getRTT(unsigned int clientID){
    167167    assert(ClientInformation::findClient(clientID));
    168168    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;
    169175  }
    170176
     
    299305    {
    300306      //ServerConnection::disconnectClient( client );
    301       ClientConnectionListener::broadcastClientDisconnected( client->getID() );
     307      //ClientConnectionListener::broadcastClientDisconnected( client->getID() ); //this is done in ClientInformation now
    302308      delete client;
    303309    }
     
    343349    GamestateManager::removeClient(client);
    344350    // inform all the listeners
    345     ClientConnectionListener::broadcastClientDisconnected(client->getID());
     351    // ClientConnectionListener::broadcastClientDisconnected(client->getID()); // this is done in ClientInformation now
    346352  }
    347353
  • code/trunk/src/libraries/network/Server.h

    r5929 r5961  
    5757    bool queuePacket(ENetPacket *packet, int clientID);
    5858    void update(const Clock& time);
    59     unsigned int getPing(unsigned int clientID);
     59    unsigned int getRTT(unsigned int clientID);
     60    virtual void printRTT();
    6061    double getPacketLoss(unsigned int clientID);
    6162  protected:
Note: See TracChangeset for help on using the changeset viewer.