Fix password generator responses (#7404)

* Respond directly to the current client instead of broadcasting

* Append requestID to generate-password response
This commit is contained in:
Sami Vänttinen 2022-02-23 00:52:51 +02:00 committed by Jonathan White
parent 6791024995
commit 7284a8062a
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
10 changed files with 500 additions and 316 deletions

View file

@ -88,18 +88,29 @@ void BrowserHost::readProxyMessage()
return;
}
emit clientMessageReceived(json.object());
emit clientMessageReceived(socket, json.object());
}
void BrowserHost::sendClientMessage(const QJsonObject& json)
void BrowserHost::broadcastClientMessage(const QJsonObject& json)
{
QString reply(QJsonDocument(json).toJson(QJsonDocument::Compact));
for (const auto socket : m_socketList) {
if (socket && socket->isValid() && socket->state() == QLocalSocket::ConnectedState) {
QByteArray arr = reply.toUtf8();
socket->write(arr.constData(), arr.length());
socket->flush();
}
sendClientData(socket, reply);
}
}
void BrowserHost::sendClientMessage(QLocalSocket* socket, const QJsonObject& json)
{
QString reply(QJsonDocument(json).toJson(QJsonDocument::Compact));
sendClientData(socket, reply);
}
void BrowserHost::sendClientData(QLocalSocket* socket, const QString& data)
{
if (socket && socket->isValid() && socket->state() == QLocalSocket::ConnectedState) {
QByteArray arr = data.toUtf8();
socket->write(arr.constData(), arr.length());
socket->flush();
}
}