- class QRemoteObjectNode¶
A node on a Qt Remote Objects network. More…
Inherited by:
QRemoteObjectHostBase
,QRemoteObjectRegistryHost
,QRemoteObjectHost
Synopsis¶
Properties¶
heartbeatIntervalᅟ
- Heartbeat interval in mspersistedStoreᅟ
- Allows setting a QRemoteObjectAbstractPersistedStore instance for the noderegistryUrlᅟ
- Address of the Registry used by this node
Methods¶
def
__init__()
def
acquireDynamic()
def
acquireModel()
def
connectToNode()
def
instances()
def
lastError()
def
persistedStore()
def
registry()
def
registryUrl()
Virtual methods¶
def
setName()
def
setRegistryUrl()
Signals¶
def
error()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
The
QRemoteObjectNode
class provides an entry point to a QtRemoteObjects network. A network can be as simple as two nodes, or an arbitrarily complex set of processes and devices.A
QRemoteObjectNode
does not have a url that other nodes can connect to, and thus is able to acquire replicas only. It is not able to share source objects (onlyQRemoteObjectHost
andQRemoteObjectRegistryHost
Nodes can share).Nodes may connect to each other directly using
connectToNode
, or they can use theQRemoteObjectRegistry
to simplify connections.The
QRemoteObjectRegistry
is a special replica available to every node that connects to the Registry Url. It knows how to connect to every QRemoteObjectSource object on the network.- class ErrorCode¶
This enum type specifies the various error codes associated with
QRemoteObjectNode
errors:Constant
Description
QRemoteObjectNode.NoError
No error.
QRemoteObjectNode.RegistryNotAcquired
The registry could not be acquired.
QRemoteObjectNode.RegistryAlreadyHosted
The registry is already defined and hosting Sources.
QRemoteObjectNode.NodeIsNoServer
The given
QRemoteObjectNode
is not a host node.QRemoteObjectNode.ServerAlreadyCreated
The host node has already been initialized.
QRemoteObjectNode.UnintendedRegistryHosting
An attempt was made to create a host
QRemoteObjectNode
and connect to itself as the registry.QRemoteObjectNode.OperationNotValidOnClientNode
The attempted operation is not valid on a client
QRemoteObjectNode
.QRemoteObjectNode.SourceNotRegistered
The given QRemoteObjectSource is not registered on this node.
QRemoteObjectNode.MissingObjectName
The given QObject does not have objectName() set.
QRemoteObjectNode.HostUrlInvalid
The given url has an invalid or unrecognized scheme.
QRemoteObjectNode.ProtocolMismatch
The client and the server have different protocol versions.
QRemoteObjectNode.ListenFailed
Can’t listen on the specified host port.
QRemoteObjectNode.SocketAccessError
The client isn’t allowed to connect to the server. Ensure that
setLocalServerOptions
is set appropriately.
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property heartbeatIntervalᅟ: int¶
This property holds Heartbeat interval in ms..
The heartbeat (only helpful for socket connections) will periodically send a message to connected nodes to detect whether the connection was disrupted. Qt Remote Objects will try to reconnect automatically if it detects a dropped connection. This function can help with that detection since the client will only detect that the server is unavailable when it tries to send data.
A value of
0
(the default) will disable the heartbeat.- Access functions:
- property persistedStoreᅟ: QRemoteObjectAbstractPersistedStore¶
This property holds Allows setting a
QRemoteObjectAbstractPersistedStore
instance for the node..Allows replica PROP members with the PERSISTED trait to save their current value when the replica is deleted and restore a stored value the next time the replica is started.
Requires a
QRemoteObjectAbstractPersistedStore
class implementation to control where and how persistence is handled.- Access functions:
This property holds The address of the
Registry
used by this node..This is an empty QUrl if there is no registry in use.
- Access functions:
Default constructor for
QRemoteObjectNode
with the givenparent
. A Node constructed in this manner can not be connected to, and thus can not expose Source objects on the network. It also will not include aQRemoteObjectRegistry
, unless set manually usingsetRegistryUrl
.See also
QRemoteObjectNode
connected to a {QRemoteObjectRegistry
} {Registry}. A Node constructed in this manner can not be connected to, and thus can not expose Source objects on the network. Finding and connecting to other (Host) Nodes is handled by theQRemoteObjectRegistry
specified byregistryAddress
.- acquireDynamic(name)¶
- Parameters:
name – str
- Return type:
Returns a
QRemoteObjectDynamicReplica
of the Sourcename
.- acquireModel(name[, action=QtRemoteObjects.FetchRootSize[, rolesHint={}]])¶
- Parameters:
name – str
action –
InitialAction
rolesHint – .list of int
- Return type:
Returns a pointer to a Replica which is specifically derived from QAbstractItemModel. The
name
provided must match the name used with the matchingenableRemoting
that put the Model on the network.action
specifies whether the model should fetch data before theinitialized
signal is emitted. If it’s set toPrefetchData
, then the data for roles in therolesHint
will be prefetched. IfrolesHint
is empty, then the data for all the roles exposed by Source will be prefetched.The returned model will be empty until it is initialized with the Source .
In order to
acquire()
Replica objects over External QIODevices , Qt Remote Objects needs access to the communications channel (a QIODevice) between the respective nodes. It is the addClientSideConnection() call that enables this, taking theioDevice
as input. Anyacquire()
call made without calling addClientSideConnection will still work, but the Node will not be able to initialize the Replica without being provided the connection to the Host node.See also
Connects a client node to the host node at
address
.Connections will remain valid until the host node is deleted or no longer accessible over a network.
Once a client is connected to a host, valid Replicas can then be acquired if the corresponding Source is being remoted.
Return
true
on success,false
otherwise (usually an unrecognized url, or connecting to already connected address).- heartbeatInterval()¶
- Return type:
int
See also
Getter of property
heartbeatIntervalᅟ
.- heartbeatIntervalChanged(heartbeatInterval)¶
- Parameters:
heartbeatInterval – int
Notification signal of property
heartbeatIntervalᅟ
.- instances(typeName)¶
- Parameters:
typeName – str
- Return type:
list of strings
This function overloads
instances()
.This convenience function provides the same result as the templated version, but takes the name of the Source class as a parameter (
typeName
) rather than deriving it from the class type.Returns the last error set.
- persistedStore()¶
- Return type:
See also
Getter of property
persistedStoreᅟ
.- registry()¶
- Return type:
Returns a pointer to the Node’s
QRemoteObjectRegistry
, if the Node is using the Registry feature; otherwise it returnsNone
.- registryUrl()¶
- Return type:
See also
Getter of property
registryUrlᅟ
.- remoteObjectAdded(arg__1)¶
- Parameters:
arg__1 – .std.pairQString,QRemoteObjectSourceLocationInfo
This signal is emitted whenever a new Source object is added to the Registry. The signal will not be emitted if there is no Registry set (i.e., Sources over connections made via
connectToNode
directly). Theloc
parameter contains the information about the added Source, including name, type and the QUrl of the hosting Node.See also
- remoteObjectRemoved(arg__1)¶
- Parameters:
arg__1 – .std.pairQString,QRemoteObjectSourceLocationInfo
This signal is emitted whenever a known Source object is removed from the Registry. The signal will not be emitted if there is no Registry set (i.e., Sources over connections made via
connectToNode
directly). Theloc
parameter contains the information about the removed Source, including name, type and the QUrl of the hosting Node.See also
- setHeartbeatInterval(interval)¶
- Parameters:
interval – int
See also
Setter of property
heartbeatIntervalᅟ
.- setName(name)¶
- Parameters:
name – str
Sets
name
as the internal name for this Node. This is then output as part of the logging (if enabled). This is primarily useful if you merge log data from multiple nodes.- setPersistedStore(persistedStore)¶
- Parameters:
persistedStore –
QRemoteObjectAbstractPersistedStore
See also
Setter of property
persistedStoreᅟ
.- waitForRegistry([timeout=30000])¶
- Parameters:
timeout – int
- Return type:
bool
Blocks until this Node’s Registry is initialized or
timeout
(in milliseconds) expires. Returnstrue
if the Registry is successfully initialized upon return, orfalse
otherwise.