Qt Remote Objects Nodes
Qt远程对象节点
In a QtRO network, information is passed between processes via QRemoteObjectNodes ("nodes"). This peer-to-peer functionality uses a small number of distinct packets passing the necessary data between nodes.
在QtRO网络中,信息通过QRemoteObjectNodes(“节点”)在进程之间传递。这种对等功能使用少量不同的数据包在节点之间传递必要的数据。
Each process that participates in the network instantiates a Node-based type, such as QRemoteObjectNode, QRemoteObjectHost, or QRemoteObjectRegistryHost. The host types of Nodes provide additional functionality. Both QRemoteObjectHost and QRemoteObjectRegistryHost support the enableRemoting() and the corresponding disableRemoting() methods, which are the key methods to expose source objects to the network. To use the Registry functionality, you need to have a QRemoteObjectRegistryHost on the network. Then, all other nodes can pass the RegistryHost's URL to the Node's registryAddress
constructor parameter, or pass the URL to the setRegistryUrl() method.
参与网络的每个进程都实例化一个基于节点的类型,如QRemoteObjectNode、QRemoteObject Host或QRemoteObjects RegistryHost。节点的主机类型提供了额外的功能。QRemoteObjectHost和QRemoteObjectRegistryHost都支持enableRemoting()和相应的disableRemoting)方法,这是向网络公开源对象的关键方法。要使用注册表功能,需要在网络上有一个QRemoteObjects RegistryHost。然后,所有其他节点可以将RegistryHost的URL传递给Node的registryAddress构造函数参数,或将URL传递给setRegistryUrl()方法。
Since QtRO is a peer-to-peer network, to acquire() a valid Replica, the replica's node needs to be connected to the node that hosts its Source. A host node is a node that allows other nodes to connect to it, which is accomplished by giving hosts unique addresses. This address is provided to the QRemoteObjectHost constructor or set by the setHostUrl method. The node from which a replica is requested must establish the connection to the host node, to initialize the replica and keep it up to date.
由于QtRO是一个对等网络,要获取()有效的副本,副本的节点需要连接到承载其源的节点。主机节点是允许其他节点连接到它的节点,这是通过为主机提供唯一地址来实现的。此地址提供给QRemoteObjectHost构造函数或由setHostUrl方法设置。请求副本的节点必须建立与主机节点的连接,以初始化副本并保持其最新状态。
Connecting Nodes using QtRO URLs
使用QtRO URL连接节点
Host Nodes use custom URLs to simplify connections. Currently, QtRO supports two types of connections:
主机节点使用自定义URL来简化连接。目前,QtRO支持两种类型的连接:
1.A TCP connection using the standard TCP/IP protocol - supports connections between devices as well as between processes on the same device.
1.使用标准TCP/IP协议的TCP连接-支持设备之间以及同一设备上进程之间的连接。
2.A local connection - supports connections between processes on the same device. This type of connection can have less overhead, depending on the underlying Operating System features.
2.本地连接-支持同一设备上进程之间的连接。根据底层操作系统功能的不同,这种连接的开销可能较小。
For local connections, you must use a unique name. For TCP connections, you must provide a unique address and port number combination.
对于本地连接,必须使用唯一的名称。对于TCP连接,必须提供唯一的地址和端口号组合。
Currently, QtRO does not include a zeroconf facility. Therefore, all processes or devices must know beforehand, how to connect to each other. A QRemoteObjectRegistry can be used to simplify the connection process for a network with multiple Host Nodes.
目前,QtRO不包括zeroconf功能。因此,所有进程或设备必须事先知道如何相互连接。QRemoteObjectRegistry可用于简化具有多个主机节点的网络的连接过程。
The table below summarizes the connection types available:
下表总结了可用的连接类型:
URL | Notes |
---|---|
("local:service") | Uses (internally) {QLocalServer}/{QLocalSocket} classes to communicate between nodes. 使用(内部){QLocalServer}/{QLocalCocket}类在节点之间进行通信。 |
("tcp://192.168.1.1:9999") | Uses (internally) {QTcpServer}/{QTcpSocket} classes to communicate between nodes. |
("qnx:service") | QNX OS only. Uses a custom (named) channel for native communication between nodes. 仅限QNX操作系统。使用自定义(命名)通道进行节点之间的本机通信。 |
("localabstract:service") | Since 6.2. Linux/Android OSes only. Uses an abstract namespace for Unix domain sockets. This allows QLocalSocket behavior to work on non-writable devices. 自6.2以来。仅限Linux/Android操作系统。为Unix域套接字使用抽象命名空间。这允许QLocalSocket行为在不可写设备上工作。 |
Nodes have a few enableRemoting() methods that are used to share objects on the network. However, if the node is not a host node, an error is returned.
节点有一些enableRemoting()方法用于在网络上共享对象。但是,如果节点不是主机节点,则会返回错误。
Other processes or devices that want to interact with a shared object can use one of the node's acquire() methods, to instantiate a replica.
其他想要与共享对象交互的进程或设备可以使用节点的acquire()方法之一来实例化副本。