From 49f3903f316ab7363b4543615d3231e1407a67ab Mon Sep 17 00:00:00 2001 From: sr Date: Wed, 6 Feb 2013 19:21:04 +0100 Subject: [SERVER] Add "stop projection" button [SERVER] Don't show error message when VNC server stops as expected [SERVER/CLIENT] Implement connection timeout of 15 seconds --- src/client/net/serverconnection.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/client/net/serverconnection.cpp') diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index 6858f54..3ccb11e 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -10,6 +10,7 @@ #include "../vnc/vncserver.h" #include "../../shared/util.h" +#include "../../shared/settings.h" #include "../util/platform/blankscreen.h" #define CHALLENGE_LEN 20 @@ -31,6 +32,8 @@ ServerConnection::ServerConnection(const QString& host, const quint16 port, cons qDebug("Connecting to %s on port %d", host.toUtf8().data(), (int)port); _socket->connectToHostEncrypted(host, port); _timerId = startTimer(4000); + _lastData = QDateTime::currentMSecsSinceEpoch() + PING_TIMEOUT_MS; + _timerConnectionCheck = startTimer(5000); // Connect the vnc start/stop signal to this class, so we can tell the server about successful vnc server startup connect(VncServer::instance(), SIGNAL(started(int, QString&, QString&)), this, SLOT(onVncServerStartStop(int, QString&, QString&))); } @@ -78,6 +81,7 @@ void ServerConnection::disconnectFromServer() void ServerConnection::handleMsg() { + _lastData = QDateTime::currentMSecsSinceEpoch() + PING_TIMEOUT_MS; const QString &id = _fromServer.getFieldString(_ID); if (_authed == 0) @@ -244,7 +248,15 @@ void ServerConnection::handleMsg() void ServerConnection::timerEvent(QTimerEvent *event) { - if (event->timerId() == _timerId) + if (event->timerId() == _timerConnectionCheck) + { + if (_lastData < QDateTime::currentMSecsSinceEpoch()) + { + this->disconnectFromServer(); + killTimer(_timerConnectionCheck); + } + } + else if (event->timerId() == _timerId) { killTimer(_timerId); _timerId = 0; -- cgit v1.2.3-55-g7522