diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index e0bf479e53..04f69ae766 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -129,11 +129,7 @@ void RiaSocketServer::slotNewClientConnection() } } - - // Get the first pending connection, and set it as the current Client to handle - - QTcpSocket *newClient = m_tcpServer->nextPendingConnection(); - this->handleClientConnection(newClient); + handlePendingIncomingConnectionRequests(); } //-------------------------------------------------------------------------------------------------- @@ -236,11 +232,14 @@ void RiaSocketServer::readCommandFromOctave() { delete m_currentCommand; m_currentCommand = NULL; + + handlePendingIncomingConnectionRequests(); + return; } } else { - // Todo: When all commands are into new shape, do the "unknown command" error output here. + handlePendingIncomingConnectionRequests(); m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data())); terminateCurrentConnection(); @@ -268,12 +267,7 @@ void RiaSocketServer::slotCurrentClientDisconnected() terminateCurrentConnection(); - QTcpSocket *newClient = m_tcpServer->nextPendingConnection(); - - if (newClient) - { - this->handleClientConnection(newClient); - } + handlePendingIncomingConnectionRequests(); } //-------------------------------------------------------------------------------------------------- @@ -312,6 +306,8 @@ void RiaSocketServer::slotReadyRead() { delete m_currentCommand; m_currentCommand = NULL; + + handlePendingIncomingConnectionRequests(); } } else @@ -336,3 +332,17 @@ int RiaSocketServer::currentCaseId() const return m_currentCaseId; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSocketServer::handlePendingIncomingConnectionRequests() +{ + QTcpSocket* newClient = m_tcpServer->nextPendingConnection(); + if (newClient) + { + terminateCurrentConnection(); + + this->handleClientConnection(newClient); + } +} + diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 26c39060b5..28c906177d 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -63,6 +63,7 @@ private: void handleClientConnection( QTcpSocket* clientToHandle); void terminateCurrentConnection(); void readCommandFromOctave(); + void handlePendingIncomingConnectionRequests(); private: QTcpServer* m_tcpServer;