0

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.

Stanton
  • 904
  • 10
  • 25
  • Most likely you need a heartbeat coming from the processor, and react to when that is lost (times out). – Kuba hasn't forgotten Monica Jun 04 '18 at 16:37
  • Yeah, a heartbeat is going to be my backup plan. I'm just surprised that there is a stateChanged signal on the Replica side but no stateChanged signal on the Source side... – Stanton Jun 05 '18 at 12:20
  • It helps to look at the full list of methods on the source side class (each class's documentation page has a prominent link to a full method list), there may be signals you want in a class it inherits from. – Kuba hasn't forgotten Monica Jun 05 '18 at 17:42
  • there is a stateChanged signal in the registry object in the QRemoteObjectHost class, but when I connect to that signal it doesn't printout when the replica is connected/disconnected. – Stanton Jun 05 '18 at 20:08

0 Answers0