mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:46:03 +00:00
RpcManager: Setup client on reconnection
This commit is contained in:
parent
e532ca8010
commit
7a83179d31
@ -55,7 +55,6 @@ ControlWorker *ControlManager::newServiceClient(QObject *parent) const
|
||||
connect(w, &ControlWorker::requestReady, this, &ControlManager::processRequest);
|
||||
|
||||
w->setServerName(getServerName(/*isService=*/true));
|
||||
w->connectToServer();
|
||||
|
||||
return w;
|
||||
}
|
||||
|
@ -110,6 +110,7 @@ void ControlWorker::setupForAsync()
|
||||
qCWarning(LC) << "Client error:" << id() << socketError << errorString();
|
||||
close();
|
||||
});
|
||||
connect(socket(), &QLocalSocket::connected, this, &ControlWorker::connected);
|
||||
connect(socket(), &QLocalSocket::disconnected, this, &ControlWorker::onDisconnected);
|
||||
connect(socket(), &QLocalSocket::readyRead, this, &ControlWorker::processRequest);
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
static QVariantList buildArgs(const QStringList &list);
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
void disconnected();
|
||||
void requestReady(Control::Command command, const QVariantList &args);
|
||||
|
||||
|
@ -368,9 +368,12 @@ void RpcManager::setupClient()
|
||||
auto controlManager = IoC()->setUpDependency<ControlManager>();
|
||||
|
||||
m_client = controlManager->newServiceClient(this);
|
||||
client()->setIsTryReconnect(true);
|
||||
|
||||
invokeOnServer(Control::Rpc_RpcManager_initClient);
|
||||
connect(client(), &ControlWorker::connected, this,
|
||||
[&] { invokeOnServer(Control::Rpc_RpcManager_initClient); });
|
||||
|
||||
client()->setIsTryReconnect(true);
|
||||
client()->connectToServer();
|
||||
}
|
||||
|
||||
void RpcManager::closeClient()
|
||||
@ -489,6 +492,7 @@ bool RpcManager::processManagerRpc(const ProcessCommandArgs &p)
|
||||
{
|
||||
if (commandRequiresValidation(p.command) && !checkClientValidated(p.worker)) {
|
||||
p.errorMessage = "Client is not validated";
|
||||
sendResult(p.worker, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user