Skip to content
QtWS25 Last Chance
  • 1 Votes
    4 Posts
    776 Views
    piseprashanthP
    Basically you missed to add addHostSideConnection on server side. Here is below code snippet. // server side void onNewServerConnection() { qDebug() << "onNewServerConnection"; bool newConn = false; if(auto tcpServer = qobject_cast<QTcpServer*>(sender())) { while(tcpServer->hasPendingConnections()) { newConn = true; m_pHost->addHostSideConnection(tcpServer->nextPendingConnection()); } } } // Use standard tcp url for the registry const QUrl registryUrl = QUrl(QStringLiteral("tcp://127.0.0.1:65212")); // Use "exttcp" for the "external" interface const QUrl extUrl = QUrl(QStringLiteral("exttcp://127.0.0.1:65213")); // Create the server and listen outside of QtRO // QTcpServer tcpServer; auto tcpServer = new QTcpServer(this); auto host = extUrl.host(); // We only know how to handle tcp:// and local: bool res = false; res = tcpServer->listen(QHostAddress(extUrl.host()), extUrl.port()); if(res) { // m_servers.insert(url, server); connect(tcpServer, &QTcpServer::newConnection, this, &YourClass::onNewServerConnection); } else { qWarning().nospace() << "server could not listen on URL: " << extUrl.toString() << ". Error type: " << tcpServer->serverError() << ", message: " << tcpServer->errorString(); delete tcpServer; } // We need a registry for everyone to connect to QRemoteObjectRegistryHost registry(registryUrl); // Finally, we create our host node and register "exttcp" as our schema. // We need the AllowExternalRegistration parameter to prevent the node from // setting a hostUrlInvalid error. m_pHost = new QRemoteObjectHost(extUrl, registryUrl, QRemoteObjectHost::AllowExternalRegistration); // From now on, when we call enableRemoting() from this node, the registry // will be updated to show the Source object at extUrl. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OnClient side // Use standard tcp url for the registry const QUrl registryUrl = QUrl(QStringLiteral("tcp://127.0.0.1:65212")); // This time create the node connected to the registry QRemoteObjectNode repNode(registryUrl); // Create the RemoteObjectSchemaHandler callback QRemoteObjectNode::RemoteObjectSchemaHandler setupTcp = [&repNode](QUrl url) -> void { QTcpSocket *socket = new QTcpSocket(&repNode); connect(socket, &QTcpSocket::connected, [socket, &repNode]() { qDebug() << "Added client side connection"; repNode.addClientSideConnection(socket); }); connect(socket, &QSslSocket::errorOccurred, [socket](QAbstractSocket::SocketError error) { qDebug() << "Deleted socket"; delete socket; }); qDebug() << "Connected to host with URL: " << url.host() <<":" << url.port(); socket->connectToHost(url.host(), url.port()); }; // Once we call registerExternalSchema, the above method will be called // whenever the registry sees an object we are interested in on "exttcp" repNode.registerExternalSchema(QStringLiteral("exttcp"), setupTcp); // local replica // QRemoteObjectNode repNode; // create remote object node // m_pHost = new QRemoteObjectHost(QUrl(ss.str().c_str())); // repNode.connectToNode(QUrl(ss.str().c_str())); //QUrl(QStringLiteral("local:replica"))); auto ptr = repNode.acquireDynamic("something");
  • Change permissions. QtRemoteObjects

    Unsolved General and Desktop qtremoteobject qtro
    1
    0 Votes
    1 Posts
    358 Views
    No one has replied
  • QRemoteObjectPendingReply ?

    Unsolved General and Desktop qtro qtremoteobject
    3
    0 Votes
    3 Posts
    1k Views
    U
    Just had the same problem, here are my findings: QRemoteObjectPendingReply inherits from QRemoteObjectPendingCall. Therefore it inherits the bool waitForFinished(int timeout = 30000) method. Example: // DeviceManagerReplica* m_deviceManager // class DeviceManagerReplica created via rep-compiler QRemoteObjectPendingReply<QStringList> result = m_deviceManager->availableDevices(); result.waitForFinished(); qCDebug(lc) << result.returnValue(); waitForFinished() seems to be a sync call, thus the m_deviceManager instance should not live in the main GUI-thread. Hope this helps.
  • QtRO exposing QList<CustomType> as a property.

    Solved General and Desktop qtremoteobject
    2
    0 Votes
    2 Posts
    860 Views
    B
    OK, I finally figure it out, It was dumb, I had to wait till the replica get sync with the source, and this by handling the QRemoteObjectReplica stateChanged event. and it's all OK now.
  • QtRemoteObject

    Unsolved General and Desktop qtremoteobject design
    1
    0 Votes
    1 Posts
    665 Views
    No one has replied