The JsonRpcClient class is used by clients to submit calls to an RPC server using JSON-RPC 2.0.
More...
#include <molequeue/client/jsonrpcclient.h>
|
unsigned int | m_packetCounter |
|
QLocalSocket * | m_socket |
|
- Author
- Marcus D. Hanwell
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:
#include <molequeue/client/jsonrpcclient.h>
request["method"] = QLatin1String("listQueues");
The JsonRpcClient class is used by clients to submit calls to an RPC server using JSON-RPC 2....
Definition jsonrpcclient.h:44
QJsonObject emptyRequest()
bool sendRequest(const QJsonObject &request)
bool connectToServer(const QString &serverName)
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.
◆ isConnected()
bool isConnected |
( |
| ) |
const |
Query if the client is connected to a server.
- Returns
- True if connected, false if not.
◆ serverName()
QString serverName |
( |
| ) |
const |
- Returns
- The server name that the client is connected to.
◆ connectToServer
bool connectToServer |
( |
const QString & |
serverName | ) |
|
|
slot |
Connect to the server.
- Parameters
-
serverName | Name of the socket to connect to. |
◆ flush
- Warning
- This should not need to be called if used in an event loop, as Qt will start writing to the socket as soon as control returns to the event loop.
◆ emptyRequest
QJsonObject emptyRequest |
( |
| ) |
|
|
slot |
Use this function to construct an empty JSON-RPC 2.0 request, with a valid request id, JSON-RPC 2.0 key etc.
- Returns
- a standard empty JSON-RPC 2.0 packet, the method etc is empty.
◆ sendRequest
bool sendRequest |
( |
const QJsonObject & |
request | ) |
|
|
slot |
Send the Json request to the RPC server.
- Parameters
-
request | The JSON-RPC 2.0 request object. |
- Returns
- True on success, false on failure.
◆ readPacket
void readPacket |
( |
const QByteArray |
message | ) |
|
|
protectedslot |
Read incoming packets of data from the server.
◆ readSocket
Read incoming data, interpret JSON stream.
◆ connectionStateChanged
void connectionStateChanged |
( |
| ) |
|
|
signal |
Emitted when the connection state changes.
◆ resultReceived
void resultReceived |
( |
QJsonObject |
message | ) |
|
|
signal |
Emitted when a result is received.
◆ notificationReceived
void notificationReceived |
( |
QJsonObject |
message | ) |
|
|
signal |
Emitted when a notification is received.
◆ errorReceived
void errorReceived |
( |
QJsonObject |
message | ) |
|
|
signal |
Emitted when an error response is received.
◆ badPacketReceived
void badPacketReceived |
( |
QString |
error | ) |
|
|
signal |
Emitted when a bad packet was received that the client could not parse.
◆ newPacket
void newPacket |
( |
const QByteArray & |
packet | ) |
|
|
signal |
Emitted when a new packet of data is received. This is handled internally, other classes should listen to resultReceived, notificationReceived, errorReceived, and badPacketReceived.
The documentation for this class was generated from the following file: