Fix issue: The wrong auth code disconnect message was not sent.
This commit is contained in:
parent
a79834755b
commit
87ea891755
|
@ -123,30 +123,36 @@ void RemoteClient::DisconnectClient(pb::remote::ReasonDisconnect reason) {
|
|||
msg.set_version(msg.default_instance().version());
|
||||
|
||||
msg.mutable_response_disconnect()->set_reason_disconnect(reason);
|
||||
SendData(&msg);
|
||||
SendDataToClient(&msg);
|
||||
|
||||
// Just close the connection. The next time the outgoing data creator
|
||||
// sends a keep alive, the client will be deleted
|
||||
client_->close();
|
||||
}
|
||||
|
||||
// Sends data to client without check if authenticated
|
||||
void RemoteClient::SendDataToClient(pb::remote::Message *msg) {
|
||||
// Serialize the message
|
||||
std::string data = msg->SerializeAsString();
|
||||
|
||||
// Check if we are still connected
|
||||
if (client_->state() == QTcpSocket::ConnectedState) {
|
||||
// write the length of the data first
|
||||
QDataStream s(client_);
|
||||
s << qint32(data.length());
|
||||
s.writeRawData(data.data(), data.length());
|
||||
|
||||
// Do NOT flush data here! If the client is already disconnected, it
|
||||
// causes a SIGPIPE termination!!!
|
||||
} else {
|
||||
client_->close();
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteClient::SendData(pb::remote::Message *msg) {
|
||||
// Check if client is authenticated before sending the data
|
||||
if (authenticated_) {
|
||||
// Serialize the message
|
||||
std::string data = msg->SerializeAsString();
|
||||
|
||||
// Check if we are still connected
|
||||
if (client_->state() == QTcpSocket::ConnectedState) {
|
||||
// write the length of the data first
|
||||
QDataStream s(client_);
|
||||
s << qint32(data.length());
|
||||
s.writeRawData(data.data(), data.length());
|
||||
|
||||
// Do NOT flush data here! If the client is already disconnected, it
|
||||
// causes a SIGPIPE termination!!!
|
||||
} else {
|
||||
client_->close();
|
||||
}
|
||||
SendDataToClient(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ public:
|
|||
RemoteClient(Application* app, QTcpSocket* client);
|
||||
~RemoteClient();
|
||||
|
||||
// This method checks if client is authenticated before sending the data
|
||||
void SendData(pb::remote::Message* msg);
|
||||
QAbstractSocket::SocketState State();
|
||||
|
||||
|
@ -27,6 +28,9 @@ private:
|
|||
void ParseMessage(const QByteArray& data);
|
||||
void DisconnectClient(pb::remote::ReasonDisconnect reason);
|
||||
|
||||
// Sends data to client without check if authenticated
|
||||
void SendDataToClient(pb::remote::Message* msg);
|
||||
|
||||
Application* app_;
|
||||
|
||||
bool use_auth_code_;
|
||||
|
|
Loading…
Reference in New Issue