summaryrefslogtreecommitdiff
path: root/client/networksender.cc
diff options
context:
space:
mode:
authordeva <deva>2006-05-25 18:18:48 +0000
committerdeva <deva>2006-05-25 18:18:48 +0000
commitd86028ba3e6c0db3c1f56077f481b3bebf883d86 (patch)
tree4d53aa133d92b40f7de46ac07f9817111379166a /client/networksender.cc
parent7d547a29164cf9318a7eca918705bbc30e93b81d (diff)
*** empty log message ***
Diffstat (limited to 'client/networksender.cc')
-rw-r--r--client/networksender.cc37
1 files changed, 37 insertions, 0 deletions
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();
+}