From d86028ba3e6c0db3c1f56077f481b3bebf883d86 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 25 May 2006 18:18:48 +0000 Subject: *** empty log message *** --- client/networksender.cc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'client/networksender.cc') diff --git a/client/networksender.cc b/client/networksender.cc index 2f1d8b0..dcb1919 100644 --- a/client/networksender.cc +++ b/client/networksender.cc @@ -37,6 +37,14 @@ NetworkSender::NetworkSender(QString cpr) // Connect // sleep(1); + server_diskspace = 0xffffffff; + server_diskspace_max = 0xffffffff; + server_load = 0xffffffff; + server_load_max = 0xffffffff; + server_ping_ms = 0xffffffff; + server_fps = -1.0; + + running = true; fprintf(stderr, "Connect [%p]\n", this); } @@ -78,6 +86,8 @@ unsigned int NetworkSender::queueSize() void NetworkSender::run() { + fprintf(stderr, " Run %p\n", this); + while(running) { if(queueSize()) semaphore.acquire(); @@ -93,9 +103,24 @@ void NetworkSender::run() sleep_1_frame(); sleep_1_frame(); delete frame; + + // TODO: Read status from network + // Set status + statusmutex.lock(); + server_diskspace_max = 1000000; + if(server_diskspace == 0xffffffff) server_diskspace = server_diskspace_max; + server_diskspace -= (int)(((double)rand() / (double)RAND_MAX) * 10.0); + + server_load = 90 + (int)(((double)rand() / (double)RAND_MAX) * 10.0); + server_load_max = 100; + server_ping_ms = (int)(((double)rand() / (double)RAND_MAX) * 100); + server_fps = 25.0; + statusmutex.unlock(); } } terminatesemaphore.release(); // Signal the stop method that the thread has stopped running. + + fprintf(stderr, " Stop %p\n", this); } void NetworkSender::stop() @@ -104,3 +129,15 @@ void NetworkSender::stop() semaphore.release(); // Kick the thread active terminatesemaphore.acquire(); // Wait for the thread to stop } + +void NetworkSender::getServerStatus(Status *status) +{ + statusmutex.lock(); + status->server_diskspace = server_diskspace; + status->server_diskspace_max = server_diskspace_max; + status->server_load = server_load; + status->server_load_max = server_load_max; + status->server_ping_ms = server_ping_ms; + status->server_fps = server_fps; + statusmutex.unlock(); +} -- cgit v1.2.3