From e605ceafa22843a7bba4c0d60c455db7f9c4e6bb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Sep 2014 15:39:23 +0200 Subject: [PATCH] Socket server : Improved server logic --- ApplicationCode/SocketInterface/RiaSocketServer.cpp | 6 +++--- ApplicationCode/SocketInterface/RiaSocketServer.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index f27c0679b0..9820cb4883 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -86,7 +86,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent) return; } - connect(m_nextPendingConnectionTimer, SIGNAL(timeout()), this, SLOT(handleNextPendingConnection())); + connect(m_nextPendingConnectionTimer, SIGNAL(timeout()), this, SLOT(slotNewClientConnection())); connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection())); } @@ -114,7 +114,7 @@ void RiaSocketServer::slotNewClientConnection() { // If we are currently handling a connection, just ignore the new one until the current one is disconnected. - if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) ) + if (m_currentClient && (m_currentClient->state() != QAbstractSocket::UnconnectedState) ) { //PMonLog("Starting Timer"); m_nextPendingConnectionTimer->start(); // Reset and start again @@ -318,7 +318,7 @@ void RiaSocketServer::terminateCurrentConnection() //-------------------------------------------------------------------------------------------------- void RiaSocketServer::handleNextPendingConnection() { - if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) ) + if (m_currentClient && (m_currentClient->state() != QAbstractSocket::UnconnectedState) ) { //PMonLog("Starting Timer"); m_nextPendingConnectionTimer->start(); // Reset and start again diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 2b55424629..1b25984f28 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -60,9 +60,9 @@ private slots: void slotNewClientConnection(); void slotCurrentClientDisconnected(); void slotReadyRead(); - void handleNextPendingConnection(); private: + void handleNextPendingConnection(); void terminateCurrentConnection(); bool readCommandFromOctave();