summaryrefslogtreecommitdiffstats
path: root/src/server/net/client.cpp
diff options
context:
space:
mode:
authorManuel Schneider2014-05-22 11:41:31 +0200
committerManuel Schneider2014-05-22 11:44:19 +0200
commitb2dd6e8b0b86446cb4d3f32403b029ee2496cc11 (patch)
tree7791fd2792b4c3ee4acb1b22c6b8bbeb20b55601 /src/server/net/client.cpp
parent[Client] Make setTutor inline and drop the communication stuff since the clie... (diff)
downloadpvs2-b2dd6e8b0b86446cb4d3f32403b029ee2496cc11.tar.gz
pvs2-b2dd6e8b0b86446cb4d3f32403b029ee2496cc11.tar.xz
pvs2-b2dd6e8b0b86446cb4d3f32403b029ee2496cc11.zip
Fix segfault. Drop nullpointer polls since SslSocket is now const. [id == _VNCCLIENT] Logical reduction. Cleanup header.
Diffstat (limited to 'src/server/net/client.cpp')
-rw-r--r--src/server/net/client.cpp39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp
index 3859f06..67b25b2 100644
--- a/src/server/net/client.cpp
+++ b/src/server/net/client.cpp
@@ -56,12 +56,8 @@ Client::Client(QSslSocket* socket) : _socket(socket)
/******************************************************************************/
Client::~Client()
{
- if (_socket != NULL)
- {
- qCritical("**** SOCKET DELETE IN DESTRUCTOR");
- _socket->deleteLater();
- }
- qDebug("*** Client %s destroyed.", qPrintable(_socket->peerAddress().toString()));
+ qDebug() << "*** Client" << _host << " destroyed.";
+ _socket->deleteLater();
}
/******************************************************************************/
@@ -90,7 +86,7 @@ void Client::timerEvent(QTimerEvent* event)
/******************************************************************************/
void Client::sendMessage(NetworkMessage& message)
{
- if (_socket == NULL || _socket->state() != QAbstractSocket::ConnectedState)
+ if (_socket->state() != QAbstractSocket::ConnectedState)
return;
message.writeMessage(_socket);
if (!message.writeComplete())
@@ -102,7 +98,7 @@ void Client::sendMessage(NetworkMessage& message)
/******************************************************************************/
void Client::requestThumb(const int width, const int height)
{
- if (_socket == NULL || _socket->state() != QAbstractSocket::ConnectedState)
+ if (_socket->state() != QAbstractSocket::ConnectedState)
{
qDebug("requestThumb called in bad state");
return;
@@ -118,13 +114,12 @@ void Client::requestThumb(const int width, const int height)
void Client::onDataArrival()
{
//
- if (_socket == NULL || _socket->state() != QAbstractSocket::ConnectedState)
+ if (_socket->state() != QAbstractSocket::ConnectedState)
{
qDebug("dataArrival called in bad state");
return;
}
- //qDebug() << _socket->bytesAvailable() << " bytes to read";
bool ret;
while (_socket->bytesAvailable())
{
@@ -138,8 +133,6 @@ void Client::onDataArrival()
{
this->handleMsg();
_fromClient.reset();
- if (_socket == NULL)
- return;
}
}
}
@@ -198,26 +191,25 @@ void Client::handleMsg()
{
// Client tells us that it started or stopped displaying a remote screen via VNC
_activeVncClient = (_fromClient.getFieldString("ENABLED").toInt() != 0);
- const int other = (int)_fromClient.getFieldString("CLIENTID").toInt();
+ const int projectionSource = (int)_fromClient.getFieldString("CLIENTID").toInt();
- const int last = _activeVncClient ? _currentProjectionSource : other;
-
- if (!_activeVncClient)
+ if (_activeVncClient)
{
- if (other == _desiredProjectionSource)
+ qDebug() << "Client " << _name << " started its VNC client (watching " << projectionSource << ")";
+ if (projectionSource == _desiredProjectionSource)
_desiredProjectionSource = 0;
- _currentProjectionSource = 0;
- qDebug() << "Client " << _name << " stopped its VNC client (watched " << last << ")";
+ emit vncClientStateChange(this, _currentProjectionSource);
+ _currentProjectionSource = projectionSource;
}
else
{
- if (other == _desiredProjectionSource)
+ qDebug() << "Client " << _name << " stopped its VNC client (watched " << projectionSource << ")";
+ if (projectionSource == _desiredProjectionSource)
_desiredProjectionSource = 0;
- _currentProjectionSource = other;
- qDebug() << "Client " << _name << " started its VNC client (watching " << other << ")";
+ emit vncClientStateChange(this, _currentProjectionSource);
+ _currentProjectionSource = 0;
}
- emit vncClientStateChange(this, last);
}
return;
}
@@ -339,7 +331,6 @@ void Client::disconnect()
qDebug("*** Client %s disconnected.", qPrintable(_socket->peerAddress().toString()));
_socket->blockSignals(true);
_socket->abort();
- _socket->deleteLater();
this->deleteLater();
emit disconnected();
}