diff options
author | Manuel Schneider | 2014-05-20 15:00:07 +0200 |
---|---|---|
committer | Manuel Schneider | 2014-05-20 15:00:07 +0200 |
commit | d19fb34169e836a8567a6caf64a1632491ae9073 (patch) | |
tree | 955078feda5f1e6ba26956261fafd7b33c274beb /src/server/net | |
parent | Remove any knowledge of Networkmesage in Mainwindow (diff) | |
download | pvs2-d19fb34169e836a8567a6caf64a1632491ae9073.tar.gz pvs2-d19fb34169e836a8567a6caf64a1632491ae9073.tar.xz pvs2-d19fb34169e836a8567a6caf64a1632491ae9073.zip |
Remvoe unneccesary membervariable _toClient and method buildErrorMessage (implicit cast does it as well)
Diffstat (limited to 'src/server/net')
-rw-r--r-- | src/server/net/client.cpp | 91 | ||||
-rw-r--r-- | src/server/net/client.h | 2 |
2 files changed, 47 insertions, 46 deletions
diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 6b3997c..9422e81 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -39,10 +39,10 @@ Client::Client(QSslSocket* socket) : _challenge.resize(CHALLENGE_LEN); for (int i = 0; i < CHALLENGE_LEN; ++i) _challenge[i] = qrand() & 0xff; - _toClient.reset(); - _toClient.setField(_ID, _CHALLENGE); - _toClient.setField(_CHALLENGE, _challenge); - _toClient.writeMessage(_socket); + NetworkMessage msgChlng; + msgChlng.setField(_ID, _CHALLENGE); + msgChlng.setField(_CHALLENGE, _challenge); + msgChlng.writeMessage(_socket); // give client 3 seconds to complete handshake _timerIdAuthTimeout = startTimer(3000); _timerPingTimeout = startTimer(600000); // for debugging purposes 10min @@ -117,11 +117,11 @@ void Client::requestThumb(const int width, const int height) qDebug("requestThumb called in bad state"); return; } - _toClient.reset(); - _toClient.setField(_ID, _THUMB); - _toClient.setField(_X, QString::number(width)); - _toClient.setField(_Y, QString::number(height)); - _toClient.writeMessage(_socket); + NetworkMessage msgTmb; + msgTmb.setField(_ID, _THUMB); + msgTmb.setField(_X, QString::number(width)); + msgTmb.setField(_Y, QString::number(height)); + msgTmb.writeMessage(_socket); } /******************************************************************************/ @@ -258,9 +258,9 @@ void Client::handleMsg() qDebug("valid, step <- 2"); _name = request.name; _host = request.host; - _toClient.reset(); - _toClient.setField(_ID, _LOGIN); - _toClient.writeMessage(_socket); + NetworkMessage msgLogin; + msgLogin.setField(_ID, _LOGIN); + msgLogin.writeMessage(_socket); emit authenticated(this); } return; @@ -276,16 +276,17 @@ void Client::handleMsg() QByteArray challenge(_fromClient.getFieldBytes(_CHALLENGE)); if (genSha1(&Global::sessionNameArray(), &_challenge) != hash) { // Challenge reply is invalid, drop client - _toClient.buildErrorMessage("Challenge reply invalid."); - _toClient.writeMessage(_socket); + NetworkMessage msgErr; + msgErr.buildErrorMessage("Challenge reply invalid."); + msgErr.writeMessage(_socket); this->disconnect(); return; } // Now answer to challenge by client - _toClient.reset(); - _toClient.setField(_ID, _CHALLENGE); - _toClient.setField(_HASH, genSha1(&Global::sessionNameArray(), &challenge)); - _toClient.writeMessage(_socket); + NetworkMessage msgChlng; + msgChlng.setField(_ID, _CHALLENGE); + msgChlng.setField(_HASH, genSha1(&Global::sessionNameArray(), &challenge)); + msgChlng.writeMessage(_socket); _authed = 1; qDebug("client's challenge reply was valid, step <- 1"); } @@ -298,60 +299,60 @@ void Client::handleMsg() void Client::startVncServer() { _vncPort = 0; - _toClient.reset(); - _toClient.setField(_ID, _VNCSERVER); - _toClient.setField(_ENABLE, __TRUE); - sendMessage(_toClient); + NetworkMessage msg; + msg.setField(_ID, _VNCSERVER); + msg.setField(_ENABLE, __TRUE); + sendMessage(msg); } /******************************************************************************/ void Client::stopVncServer() { - _toClient.reset(); - _toClient.setField(_ID, _VNCSERVER); - _toClient.setField(_ENABLE, __FALSE); - sendMessage(_toClient); + NetworkMessage msg; + msg.setField(_ID, _VNCSERVER); + msg.setField(_ENABLE, __FALSE); + sendMessage(msg); } /******************************************************************************/ void Client::stopVncClient() { _activeVncClient = false; - _toClient.reset(); - _toClient.setField(_ID, _VNCCLIENT); - sendMessage(_toClient); + NetworkMessage msg; + msg.setField(_ID, _VNCCLIENT); + sendMessage(msg); } /******************************************************************************/ void Client::startVncClient(QString host, int port, QString pass, int id, QString caption) { _activeVncClient = false; - _toClient.reset(); - _toClient.setField(_ID, _VNCCLIENT); - _toClient.setField("HOST", host); - _toClient.setField("PORT", QString::number(port)); - _toClient.setField("ROPASS", pass); - _toClient.setField("CLIENTID", QString::number(id)); - _toClient.setField("CAPTION", caption); - sendMessage(_toClient); + NetworkMessage msg; + msg.setField(_ID, _VNCCLIENT); + msg.setField("HOST", host); + msg.setField("PORT", QString::number(port)); + msg.setField("ROPASS", pass); + msg.setField("CLIENTID", QString::number(id)); + msg.setField("CAPTION", caption); + sendMessage(msg); } /******************************************************************************/ void Client::lockScreen(bool lock) { - _toClient.reset(); - _toClient.setField(_ID, _LOCK); - _toClient.setField(_ENABLE, lock ? __TRUE : __FALSE); - sendMessage(_toClient); + NetworkMessage msg; + msg.setField(_ID, _LOCK); + msg.setField(_ENABLE, lock ? __TRUE : __FALSE); + sendMessage(msg); } /******************************************************************************/ void Client::setTutor(bool enable) { - _toClient.reset(); - _toClient.setField(_ID, _TUTOR); - _toClient.setField(_ENABLE, _BOOL(enable)); - sendMessage(_toClient); + NetworkMessage msg; + msg.setField(_ID, _TUTOR); + msg.setField(_ENABLE, _BOOL(enable)); + sendMessage(msg); _isTutor = enable; } diff --git a/src/server/net/client.h b/src/server/net/client.h index e9bd46b..e0bdfe8 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -61,7 +61,7 @@ private: QString _ip; QByteArray _challenge; qint64 _pingTimeout; - NetworkMessage _toClient, _fromClient; + NetworkMessage _fromClient; int _timerIdAuthTimeout, _timerDelete, _timerPingTimeout; int _id; // this client's unique id // If this client should be projected to from another client, the other |