I'm using Qt's QtRemoteObject
module to run processes across many devices. The current architecture is there is a Host machine (call it the ManagerNode) which creates the Source object, then there are many other remote computers that run on a local area network (call them processor nodes). As the many processor nodes startup I have been successful in getting them to connect to the ManagerNode. Once connected communication via signals/slots has been pretty trivial.
My question is: On the ManagerNode I would like to latch on to some sort of signal when each of the processorNodes are connected as well as when the processorNodes are disconnected (i.e. due to internet interruptions / computer crashes).
Here are some snippets of my code:
Host/main.cpp
#include <QCoreApplication>
#include "simpleswitch.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QRemoteObjectRegistryHost regHost(QUrl("tcp://10.81.2.42"));
QRemoteObjectHost host;
host.setHostUrl(QUrl("tcp://10.81.2.42:1"));
host.setRegistryUrl(QUrl("tcp://10.81.2.42"));
SimpleSwitch simpleSwitch;
host.enableRemoting(&simpleSwitch);
return a.exec();
}
Replica/main.cpp
#include <QCoreApplication>
#include "client.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QRemoteObjectNode node(QUrl("tcp://10.81.2.42"));
while (!node.waitForRegistry(1000));
qDebug() << "Registry is Setup";
QSharedPointer<SimpleSwitchReplica> ptr;
ptr.reset(node.acquire<SimpleSwitchReplica>());
Client rswitch(ptr);
return a.exec();
}
I've found in the SimpleSwitchReplica class there is a signal for StateChanged
and this works whenever there is a connection/disconnection from the ManagerNode. But this signal is emitted on the ProcessorNode whereas I want the signal on the ManagerNode...
Any help on this would be greatly appreciated.