From 4e569d5fec319d4fdc95c21bd704fcd321c07305 Mon Sep 17 00:00:00 2001 From: Johann Latocha Date: Wed, 1 Jun 2011 13:58:21 +0200 Subject: Enhancement #821 --- src/net/pvsListenServer.cpp | 11 +++++++---- src/net/pvsListenServer.h | 1 + src/setup.h | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/net/pvsListenServer.cpp b/src/net/pvsListenServer.cpp index 90c2dfb..1280a92 100644 --- a/src/net/pvsListenServer.cpp +++ b/src/net/pvsListenServer.cpp @@ -28,6 +28,7 @@ #include //#define verbose #include "mcast/McastConfiguration.h" +#include // Create listener PVSListenServer::PVSListenServer(int port, int clients) @@ -123,13 +124,13 @@ bool PVSListenServer::shutdown() return false; } -// timer event, 5 second interval +// timer event, CLIENT_TIMEOUT interval void PVSListenServer::timerEvent(QTimerEvent *event) { if (!(_clients.empty())) { // Check for ping timeout - time_t refval = time(NULL) - 10; + time_t refval = time(NULL) - (CLIENT_TIMEOUT/1000); for (std::list::iterator it = _clients.begin(); it != _clients.end(); it++) { @@ -140,9 +141,11 @@ void PVSListenServer::timerEvent(QTimerEvent *event) if (disconnectClient(client)) break; // list was modified, iterator not valid anymore } + qDebug() << client->lastData() << " " << refval; if (client->lastData() < refval) { // ping timeout - qDebug("Ping timeout for client %s", qPrintable(client->getNameUser())); + qDebug("DEBUG: Ping timeout for client %s", qPrintable(client->getNameUser())); + qDebug("DEBUG: Timeout was %i last response was %i", refval, client->lastData()); if (disconnectClient(client)) break; // list was modified, iterator not valid anymore } @@ -264,7 +267,7 @@ bool PVSListenServer::init() _fresh = true; if (_timer != 0) killTimer( _timer); - _timer = startTimer(5000); + _timer = startTimer(CLIENT_KEEPALIVE); return true; } return false; diff --git a/src/net/pvsListenServer.h b/src/net/pvsListenServer.h index ca9977c..99b6e35 100644 --- a/src/net/pvsListenServer.h +++ b/src/net/pvsListenServer.h @@ -5,6 +5,7 @@ #include #include //#include +#include "../setup.h" class SslServer; diff --git a/src/setup.h b/src/setup.h index 4a21754..879db1c 100644 --- a/src/setup.h +++ b/src/setup.h @@ -10,4 +10,7 @@ #define SD_PORT_CONSOLE 3491 // Not really used, Qt just wants a bind #define SD_PORT_CLIENT 3492 // This is where we expect announcements +#define CLIENT_KEEPALIVE 5000 // Clients ping rate +#define CLIENT_TIMEOUT 15000 // Timeout to check if clients are alive + #endif -- cgit v1.2.3-55-g7522