#include <Pt/JsonRpc/HttpClient.h>
A client for JSON-RPC 2.0 remote procedure calls via HTTP.
Inherits Client, and Connectable.
|
|
| HttpClient () |
| | Constructor.
|
|
| HttpClient (const Net::Endpoint &ep, const std::string &url) |
| | Construct with host and service URL.
|
|
| HttpClient (System::EventLoop &loop) |
| | Construct with EventLoop used for I/O.
|
|
| HttpClient (System::EventLoop &loop, const Net::Endpoint &ep, const std::string &url) |
| | Construct with host and service URL.
|
|
virtual | ~HttpClient () |
| | Destructor.
|
|
void | setActive (System::EventLoop &loop) |
| | Sets the EventLoop to use for I/O.
|
|
System::EventLoop * | loop () const |
| | Gets the used EventLoop.
|
|
void | setSecure (Ssl::Context &ctx) |
| | Sets SSL context.
|
|
void | setPeerName (const std::string &peer) |
| | Set expected SSL peer name.
|
|
void | setKeepAlive () |
| | Enables HTTP keep-alive.
|
|
void | setTimeout (std::size_t timeout) |
| | Sets timeout for I/O operations.
|
|
void | setTarget (const Net::Endpoint &ep, const std::string &url) |
| | Sets target host and service URL.
|
|
void | setTarget (const Net::Endpoint &ep, const Net::TcpSocketOptions &opts, const std::string &url) |
| | Sets target host and service URL.
|
|
void | setHost (const Net::Endpoint &ep) |
| | Sets host to connect.
|
|
void | setHost (const Net::Endpoint &ep, const Net::TcpSocketOptions &opts) |
| | Sets host to connect.
|
|
void | setServiceUrl (const std::string &url) |
| | Sets the service URL.
|
|
void | setServiceUrl (const char *url) |
| | Sets the service URL.
|
|
const Net::Endpoint & | host () const |
| | Returns target host.
|
|
void | close () |
| | Closes the connection.
|
| void | setProcedure (const ProcedureDeclaration *decl) |
| | Set procedure declaration for named parameters.
|
|
const RemoteCall * | activeProcedure () const |
| | The currently executing procedure.
|
|
void | cancel () |
| | Cancels the currently executing procedure.
|
|
|
virtual bool | isFailed () const |
| | Indicates if the procedure has failed.
|
| virtual void | onBeginInvoke () |
| | Begin an asynchronous invocation.
|
| virtual void | onInvoke () |
| | Perform a synchronous invocation.
|
|
virtual void | onEndInvoke () |
| | End an asynchronous invocation.
|
| virtual void | onCancel () |
| | Cancels the remote procedure call.
|
|
void | beginMessage (std::ostream &os) |
| | Begin formatting a JSON-RPC request to a stream.
|
| bool | advanceMessage () |
| | Continue formatting the request.
|
|
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.
|
|
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.
|
◆ onBeginInvoke()
| virtual void onBeginInvoke |
( |
| ) |
|
|
protectedvirtual |
Derived Clients implement this to send the formatted request.
Implements Client.
◆ onInvoke()
| virtual void onInvoke |
( |
| ) |
|
|
protectedvirtual |
Derived Clients implement this to send the request and receive the response.
Implements Client.
◆ onCancel()
| virtual void onCancel |
( |
| ) |
|
|
protectedvirtual |
Derived Clients implement this method to cancel the remote procedure call.
Reimplemented from Client.
◆ setProcedure()
If set, parameters will be sent as a JSON object with named keys. If not set, parameters are sent as a JSON array.
◆ advanceMessage()
- Returns
- true if all parameters are formatted.
◆ parseResult()
- Returns
- true if parsing is complete.
◆ setReady()
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.