added ping times to UI

This commit is contained in:
Mark Vejvoda
2010-06-04 19:42:58 +00:00
parent 54a2a36140
commit 964be91fa9
12 changed files with 221 additions and 15 deletions

View File

@@ -20,6 +20,7 @@
#include <map>
#include <vector>
#include "base_thread.h"
#include "simple_threads.h"
using std::string;
@@ -70,7 +71,7 @@ public:
// class Socket
// =====================================================
class Socket {
class Socket : public SimpleTaskCallbackInterface {
#ifdef WIN32
@@ -90,12 +91,20 @@ protected:
PLATFORM_SOCKET sock;
time_t lastDebugEvent;
static int broadcast_portno;
std::string ipAddress;
SimpleTaskThread *pingThread;
std::map<string,float> pingCache;
time_t lastThreadedPing;
Mutex pingThreadAccessor;
public:
Socket(PLATFORM_SOCKET sock);
Socket();
virtual ~Socket();
virtual void simpleTask();
static int getBroadCastPort() { return broadcast_portno; }
static void setBroadCastPort(int value) { broadcast_portno = value; }
static std::vector<std::string> getLocalIPAddressList();
@@ -125,6 +134,12 @@ public:
bool isSocketValid() const;
static bool isSocketValid(const PLATFORM_SOCKET *validateSocket);
static float getAveragePingMS(std::string host, int pingCount=5);
float getThreadedPingMS(std::string host);
virtual std::string getIpAddress();
virtual void setIpAddress(std::string value) { ipAddress = value; }
protected:
static void throwException(string str);
};