Responder Class Referenceabstract

#include <Pt/JsonRpc/Responder.h>

Dispatches JSON-RPC requests to a service procedure.

Inherits Responder.

Public Member Functions

 Responder (const ServiceDeclaration &decl, Remoting::ServiceDefinition &def)
 Construct with ServiceDeclaration and ServiceDefinition.
 
virtual ~Responder ()
 Destructor.
 
bool isFailed () const
 Indicates if the procedure has failed.
 
void cancel ()
 Resets to initial state.
 
const ServiceProcedure * activeProcedure () const
 The currently executing procedure.
 

Protected Member Functions

virtual void onReady ()
 The service procedure has finished. More...
 
virtual void onCancel ()
 Cancels all operations. More...
 
virtual void onFault (const Fault &fault)=0
 The service procedure has failed. More...
 
virtual void onResult ()=0
 The service procedure has finished. More...
 
void beginMessage (std::istream &is)
 Begin parsing a JSON-RPC request from a stream.
 
bool parseMessage ()
 Parse available data from the input stream. More...
 
void finishMessage (System::EventLoop &loop)
 Execute the service procedure after parsing completes.
 
void finishMessage ()
 Execute the service procedure synchronously.
 
void beginResult (std::ostream &os)
 Begin formatting a JSON-RPC success response.
 
void beginFault (std::ostream &os, const Fault &fault)
 Begin formatting a JSON-RPC error response.
 
bool advanceResult ()
 Continue formatting the result. More...
 
void finishResult ()
 Finish formatting the result response.
 
void setFault (int rc, const char *msg)
 Mark the procedure as failed.
 
Pt::Composer ** setProcedure (const std::string &name)
 Sets the service procedure.
 
void beginCall (System::EventLoop &loop)
 Begins the service procedure call.
 
Pt::DecomposerendCall ()
 Ends the service procedure call.
 
Pt::Decomposercall ()
 Synchronous call without EventLoop.
 

Member Function Documentation

◆ onReady()

virtual void onReady ( )
protectedvirtual

Derived responders implement this method to format and send the XML-RPC result. It is called when the service procedure has finished. Use beginResult(), advanceResult() and finishResult() to format the XML-RPC result.

Implements Responder.

◆ onCancel()

virtual void onCancel ( )
protectedvirtual

Derived responders implement this method to cancel all operations.

Implements Responder.

◆ onFault()

virtual void onFault ( const Fault fault)
protectedpure virtual

Derived responders implement this method to format and send the JSON-RPC error response. Use beginFault() to format the response.

◆ onResult()

virtual void onResult ( )
protectedpure virtual

Derived responders implement this method to format and send the JSON-RPC result. Use beginResult(), advanceResult() and finishResult() to format the response.

◆ parseMessage()

bool parseMessage ( )
protected

Each call consumes available data. Returns true if parsing is complete (success or error).

◆ advanceResult()

bool advanceResult ( )
protected
Returns
true if the result is fully formatted.