Client Class Referenceabstract

#include <Pt/JsonRpc/Client.h>

A client for JSON-RPC 2.0 remote procedure calls.

Inherits Client.

Inherited by HttpClient.

Public Member Functions

 Client ()
 Constructor.
 
virtual ~Client ()
 Destructor.
 
bool isFailed () const
 Indicates if the procedure has failed.
 
void setProcedure (const ProcedureDeclaration *decl)
 Set procedure declaration for named parameters. More...
 
const RemoteCall * activeProcedure () const
 The currently executing procedure.
 
void cancel ()
 Cancels the currently executing procedure.
 

Protected Member Functions

virtual void onCancel ()
 Cancels the remote procedure call. More...
 
virtual void onBeginInvoke ()=0
 Begin an asynchronous invocation. More...
 
virtual void onEndInvoke ()=0
 End an asynchronous invocation.
 
virtual void onInvoke ()=0
 Perform a synchronous invocation. More...
 
void beginMessage (std::ostream &os)
 Begin formatting a JSON-RPC request to a stream.
 
bool advanceMessage ()
 Continue formatting the request. More...
 
void finishMessage ()
 Finish formatting the request.
 
void beginResult (std::istream &is)
 Begin parsing a JSON-RPC response from a stream.
 
bool parseResult ()
 Parse available response data. More...
 
void processResult (std::istream &is)
 Parse the entire response synchronously.
 
void setFault (int rc, const char *msg)
 Mark the current procedure as failed.
 
void setReady ()
 Parses the XML-RPC result. More...
 

Member Function Documentation

◆ setProcedure()

void setProcedure ( const ProcedureDeclaration decl)

If set, parameters will be sent as a JSON object with named keys. If not set, parameters are sent as a JSON array.

◆ onCancel()

virtual void onCancel ( )
protectedvirtual

Derived Clients implement this method to cancel the remote procedure call.

Implements Client.

Reimplemented in HttpClient.

◆ onBeginInvoke()

virtual void onBeginInvoke ( )
protectedpure virtual

Derived Clients implement this to send the formatted request.

Implemented in HttpClient.

◆ onInvoke()

virtual void onInvoke ( )
protectedpure virtual

Derived Clients implement this to send the request and receive the response.

Implemented in HttpClient.

◆ advanceMessage()

bool advanceMessage ( )
protected
Returns
true if all parameters are formatted.

◆ parseResult()

bool parseResult ( )
protected
Returns
true if parsing is complete.

◆ setReady()

void setReady ( )
protectedinherited

This method is used by derived Clients after the XML-RPC result has been parsed by parseResult(). The current RemoteProcedure will receive completion notification to process the result.