Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2009


Ignore:
Timestamp:
Oct 24, 2008, 4:00:00 PM (15 years ago)
Author:
scheusso
Message:

server is now able to deliver ping time and packet loss ratio for all its clients

Location:
code/branches/objecthierarchy/src/network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/ClientInformation.cc

    r1990 r2009  
    162162
    163163  enet_uint32 ClientInformation::getRTT(){
    164     return peer_->roundTripTime;
    165   }
    166 
    167   enet_uint32 ClientInformation::getPacketLoss(){
    168     return peer_->packetLoss;
     164    return this->peer_->roundTripTime;
     165  }
     166
     167  double ClientInformation::getPacketLoss(){
     168    return ((double)this->peer_->packetLoss)/ENET_PEER_PACKET_LOSS_SCALE;
    169169  }
    170170
  • code/branches/objecthierarchy/src/network/ClientInformation.h

    r1960 r2009  
    8585    void resetFailures();
    8686    enet_uint32 getRTT();
    87     enet_uint32 getPacketLoss();
     87    double getPacketLoss();
    8888
    8989    static bool removeClient(unsigned int clientID);
  • code/branches/objecthierarchy/src/network/Server.cc

    r1953 r2009  
    163163    return connection->addPacket(packet, clientID);
    164164  }
    165 
     165 
     166  /**
     167   * @brief: returns ping time to client in milliseconds
     168   */
     169  unsigned int Server::getPing(unsigned int clientID){
     170    assert(ClientInformation::findClient(clientID));
     171    return ClientInformation::findClient(clientID)->getRTT();
     172  }
     173
     174  /**
     175   * @brief: return packet loss ratio to client (scales from 0 to 1)
     176   */
     177  double Server::getPacketLoss(unsigned int clientID){
     178    assert(ClientInformation::findClient(clientID));
     179    return ClientInformation::findClient(clientID)->getPacketLoss();
     180  }
     181 
    166182  /**
    167183  * processes all the packets waiting in the queue
  • code/branches/objecthierarchy/src/network/Server.h

    r1953 r2009  
    7070    bool queuePacket(ENetPacket *packet, int clientID);
    7171    void tick(float time);
     72    unsigned int getPing(unsigned int clientID);
     73    double getPacketLoss(unsigned int clientID);
    7274  protected:
    7375    void processQueue();
Note: See TracChangeset for help on using the changeset viewer.