#include <molequeue/client/jsonrpcclient.h>
Public Slots | |
bool | connectToServer (const QString &serverName) |
void | flush () |
QJsonObject | emptyRequest () |
bool | sendRequest (const QJsonObject &request) |
Signals | |
void | connectionStateChanged () |
void | resultReceived (QJsonObject message) |
void | notificationReceived (QJsonObject message) |
void | errorReceived (QJsonObject message) |
void | badPacketReceived (QString error) |
void | newPacket (const QByteArray &packet) |
Public Member Functions | |
JsonRpcClient (QObject *parent_=0) | |
bool | isConnected () const |
QString | serverName () const |
Protected Slots | |
void | readPacket (const QByteArray message) |
void | readSocket () |
Protected Attributes | |
unsigned int | m_packetCounter |
QLocalSocket * | m_socket |
The JsonRpcClient class is used by clients to submit calls to an RPC server using JSON-RPC 2.0.
Provides a simple Qt C++ API to make JSON-RPC 2.0 calls to an RPC server. To create a client connection and call a method the following should be done:
You should connect to the appropriate signals in order to act on results, notifications and errors received in response to requests set using the client connection.
bool isConnected | ( | ) | const |
Query if the client is connected to a server.
QString serverName | ( | ) | const |
|
slot |
Connect to the server.
serverName | Name of the socket to connect to. |
|
slot |
flush Flush all pending messages to the server.
|
slot |
Use this function to construct an empty JSON-RPC 2.0 request, with a valid request id, JSON-RPC 2.0 key etc.
|
slot |
Send the Json request to the RPC server.
request | The JSON-RPC 2.0 request object. |
|
protectedslot |
Read incoming packets of data from the server.
|
protectedslot |
Read incoming data, interpret JSON stream.
|
signal |
Emitted when the connection state changes.
|
signal |
Emitted when a result is received.
|
signal |
Emitted when a notification is received.
|
signal |
Emitted when an error response is received.
|
signal |
Emitted when a bad packet was received that the client could not parse.
|
signal |
Emitted when a new packet of data is received. This is handled internally, other classes should listen to resultReceived, notificationReceived, errorReceived, and badPacketReceived.