![]() |
Home · Modules · Classes · Namespaces · Functions |
The QxtRPCService class transmits Qt signals over a QIODevice More...
#include <QxtRPCService>
Inherits QObject.
Inherited by QxtRPCPeer.
The QxtRPCService class transmits Qt signals over a QIODevice
QxtRPCService is a tool that encapsulates Qt signals and transmits them over a QIODevice. The signal is subsequently re-emitted on the receiving end of the connection.
QxtRPCService can act as a client or a server. When acting as a server, it uses a QxtAbstractConnectionManager to accept connections. When acting as a client, the application should provide an already-connected QIODevice to the setDevice() function.
All data types used in attached signals and slots must be declared and registered with QMetaType using Q_DECLARE_METATYPE and qRegisterMetaType. Additional requirements may be imposed by the QxtAbstractSignalSerializer subclass in use; the default (QxtDataStreamSignalSerializer) requires that they have stream operators registered with qRegisterMetaTypeStreamOperators.
Due to a restriction of Qt's signals and slots mechanism, the number of parameters that can be passed to call() and its related functions, as well as the number of parameters to any signal or slot attached to QxtRPCService, is limited to 8.
Creates a QxtRPCService object with the given parent.
Creates a QxtRPCService object with the given parent and connects it to the specified I/O device.
The I/O device must already be opened for reading and writing.
Destroys the QxtRPCService object.
Attaches the given signal.
When the attached signal is emitted by sender, it will be transmitted to all connected servers, clients, or peers. If an optional rpcFunction is provided, it will be used in place of the name of the transmitted signal. Use the SIGNAL() macro to specify the signal, just as you would for QObject::connect().
Like QObject::connect(), attachSignal() returns false if the connection cannot be established.
Attaches an RPC function to the given slot.
When a signal with the name given by rpcFunction is received from the network, the attached slot is executed. Use the SLOT() macro to specify the slot, just as you would for QObject::connect().
Like QObject::connect(), attachSlot() returns false if the connection cannot be established. Also like QObject::connect(), a signal may be used as a slot; invocation will cause the signal to be emitted.
Note: When acting like a server, the first parameter of the slot must be <b>quint64 id</b>. The parameters of the incoming signal follow. For example, SIGNAL(mySignal(QString)) from the client connects to SLOT(mySlot(quint64, QString)) on the server.
Sends the signal fn with the given parameter list to the server, or to all connected clients.
The receiver is not obligated to act upon the signal. If no clients are connected, and if not communicating with a server, this function does nothing.
Sends the signal fn with the given parameter list to the provided list of clients.
The receivers are not obligated to act upon the signal. If no client is connected with a provided ID, the ID is ignored with a warning. If acting as a client, this function does nothing.
Sends the signal fn with the given parameter list to the specified client.
The receiver is not obligated to act upon the signal. If no client with the given ID is connected, the call will be ignored with a warning. If acting as a client, this function does nothing.
Sends the signal fn with the given parameter list to all connected clients except for the client specified.
The receiver is not obligated to act upon the signal. This function is useful for rebroadcasting a signal from one client to all other connected clients. If acting as a client, this function does nothing.
Returns a list of client IDs for all connected clients.
Returns the connection manager used to accept incoming connections.
See also setConnectionManager().
Detaches all signals and slots for the given object obj.
Detaches all signals and slots for the object that emitted the signal connected to detachSender().
Detaches all signals for the given object obj.
* Detaches all slots for the given object obj.
When operating as a client, returns the QIODevice connected to the server. When operating as a server, or if not connected to a server, returns NULL.
See also setDevice() and takeDevice().
Disconnects all clients, or disconnects from the server.
Disconnects a client with id using the attached connection manager.
If connected to a server, this function is ignored with a warning.
Disconnects from the server. The QIODevice is deleted. Use takeDevice() to disconnect from the server without deleting the device.
If not connected to a server, for instance if acting as a server, this function is ignored with a warning.
See also device() and takeDevice().
Returns true if the QxtRPCService is currently communicating with a server. It is possible for both isServer() and isClient() to return false if the connection manager is not accepting connections, no clients are connected, and no QIODevice is set for a server.
See also isServer().
Returns true if the connection manager is accepting connections or if any clients are currently connected. It is possible for both isServer() and isClient() to return false if the connection manager is not accepting connections, no clients are connected, and no QIODevice is set for a server.
See also isClient().
Returns the signal serializer used to encode signals before transmission.
See also setSerializer().
Sets the connection manager used to accept incoming connections. The existing manager will be deleted and the provided manager will be reparented to the QxtRPCService.
See also connectionManager().
Begins communicating with a server through the provided QIODevice dev. If called while acting as a server, this function is ignored with a warning. If called while another device is set, the original QIODevice is deleted. The provided device will be reparented to the QxtRPCService.
Note that because QIODevice is a generic interface, QxtRPCService cannot provide signals when this device is disconnected or has low-level errors. Connect to the QIODevice subclass's signals directly if you need this information.
See also device().
Sets the signal serializer used to encode signals before transmission. The existing serializer will be deleted.
See also serializer().
When operating as a client, returns the QIODevice used to communicate with the server. After this function is called, the QxtRPCService will no longer be connected and device() will return NULL. When operating as a server, or if not connected to a server, this function returns NULL without any other effect.
See also device().
Copyright © 2007-2010 Qxt Foundation |
Qxt 0.6.1 |