diff options
author | sr | 2013-02-06 19:21:04 +0100 |
---|---|---|
committer | sr | 2013-02-06 19:21:04 +0100 |
commit | 49f3903f316ab7363b4543615d3231e1407a67ab (patch) | |
tree | 9f6ec082403f388c0e791de68b1743000a12bc49 /src/client/net/serverconnection.cpp | |
parent | ... (diff) | |
download | pvs2-49f3903f316ab7363b4543615d3231e1407a67ab.tar.gz pvs2-49f3903f316ab7363b4543615d3231e1407a67ab.tar.xz pvs2-49f3903f316ab7363b4543615d3231e1407a67ab.zip |
[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
Diffstat (limited to 'src/client/net/serverconnection.cpp')
-rw-r--r-- | src/client/net/serverconnection.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
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; |