MoleQueue 0.9.0
Loading...
Searching...
No Matches
JsonRpc Class Reference

#include <molequeue/servercore/jsonrpc.h>

Inheritance diagram for JsonRpc:

Signals

void messageReceived (const MoleQueue::Message &message)
 

Public Member Functions

 JsonRpc (QObject *parent_=0)
 
void addConnectionListener (MoleQueue::ConnectionListener *connlist)
 
void removeConnectionListener (MoleQueue::ConnectionListener *connlist)
 

Detailed Description

The JsonRpc class manages ConnectionListener and Connection instances, and emits incoming JSON-RPC Messages.

Author
David C. Lonie

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:

  • -32600 Invalid request
    • The message type could not be determined.
  • -32603 Internal error
    • Internal JSON-RPC error
  • -32700 Parse error
    • Invalid JSON received, an error occurred during parsing.

The remaining standard JSON-RPC error codes should be handled by the application developer when messageReceived:

  • -32601 Method not found
    • Method not supported by application
  • -32602 Invalid params
    • Inappropriate parameters supplied for requested method.

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.

Member Function Documentation

◆ addConnectionListener()

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.

◆ removeConnectionListener()

void removeConnectionListener ( MoleQueue::ConnectionListener * connlist)

Unregister a connection listener from this JsonRpc instance. Any connections owned by this listener will be unregistered as well.

Parameters
connlist

◆ messageReceived

void messageReceived ( const MoleQueue::Message & message)
signal

Emitted when a valid message is received.


The documentation for this class was generated from the following file: