#include <molequeue/servercore/jsonrpc.h>
Signals | |
void | messageReceived (const MoleQueue::Message &message) |
Public Member Functions | |
JsonRpc (QObject *parent_=0) | |
void | addConnectionListener (MoleQueue::ConnectionListener *connlist) |
void | removeConnectionListener (MoleQueue::ConnectionListener *connlist) |
The JsonRpc class manages ConnectionListener and Connection instances, and emits incoming JSON-RPC Messages.
To use the JsonRpc class, create one or more ConnectionListener instances and call addConnectionListener(). Connect a slot to messageReceived and handle any incoming messages.
This class will handle the following standard JSON-RPC errors:
The remaining standard JSON-RPC error codes should be handled by the application developer when messageReceived:
Incoming requests with method="internalPing" will be automatically replied to with result="pong". This can be used to test if a server is alive or not. messageReceived will not be emitted in this case.
Use Message::generateResponse() and Message::generateErrorResponse() to easily create replies to incoming requests.
void addConnectionListener | ( | MoleQueue::ConnectionListener * | connlist | ) |
Register a connection listener with this JsonRpc instance. Any incoming connections on the listener will be monitored by this class and all incoming messages will be treated as JSON-RPC transmissions. This class does not take ownership of the listener, and will automatically remove it from any internal data structures if it is destroyed.
void removeConnectionListener | ( | MoleQueue::ConnectionListener * | connlist | ) |
Unregister a connection listener from this JsonRpc instance. Any connections owned by this listener will be unregistered as well.
connlist |
|
signal |
Emitted when a valid message is received.