summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-06 18:46:17 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-06 18:46:17 +0000
commit383339dedf6f1a52b8d6b0196068232daec83526 (patch)
treefe8bca4bc6b45e83d5c8e70a2ff1e1af4d1b99ae /src/net
parent593e65eef0d43f2ff61dc1b4f3160c0a16b5f015 (diff)
downloadmanaserv-383339dedf6f1a52b8d6b0196068232daec83526.tar.gz
manaserv-383339dedf6f1a52b8d6b0196068232daec83526.tar.bz2
manaserv-383339dedf6f1a52b8d6b0196068232daec83526.tar.xz
manaserv-383339dedf6f1a52b8d6b0196068232daec83526.zip
Removed world timer usage from account server, instead letting ENet wait during
each host service to reduce CPU usage. Modified timer code to gracefully handle jumps back in time.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/connectionhandler.cpp4
-rw-r--r--src/net/connectionhandler.hpp5
2 files changed, 6 insertions, 3 deletions
diff --git a/src/net/connectionhandler.cpp b/src/net/connectionhandler.cpp
index 69ac9337..53ec3446 100644
--- a/src/net/connectionhandler.cpp
+++ b/src/net/connectionhandler.cpp
@@ -85,11 +85,11 @@ void ConnectionHandler::flush()
enet_host_flush(host);
}
-void ConnectionHandler::process()
+void ConnectionHandler::process(enet_uint32 timeout)
{
ENetEvent event;
// Process Enet events and do not block.
- while (enet_host_service(host, &event, 0) > 0) {
+ while (enet_host_service(host, &event, timeout) > 0) {
switch (event.type) {
case ENET_EVENT_TYPE_CONNECT:
{
diff --git a/src/net/connectionhandler.hpp b/src/net/connectionhandler.hpp
index df22aacc..76bea198 100644
--- a/src/net/connectionhandler.hpp
+++ b/src/net/connectionhandler.hpp
@@ -60,8 +60,11 @@ class ConnectionHandler
/**
* Process outgoing messages and listen to the server socket for
* incoming messages and new connections.
+ *
+ * @timeout an optional timeout in milliseconds to wait for something
+ * to happen when there is nothing to do
*/
- virtual void process();
+ virtual void process(enet_uint32 timeout = 0);
/**
* Process outgoing messages.