CppCMS
Classes | Public Types | Public Member Functions
cppcms::rpc::json_rpc_server Class Reference

JSON-RPC service application. More...

#include <cppcms/rpc_json.h>

Inheritance diagram for cppcms::rpc::json_rpc_server:
cppcms::application booster::noncopyable

List of all members.

Classes

struct  method_data

Public Types

enum  role_type { any_role, method_role, notification_role }
typedef booster::function
< void(json::array const &)> 
method_type

Public Member Functions

void bind (std::string const &name, method_type const &, role_type type=any_role)
void smd (json::value const &)
void smd_raw (std::string const &)
void smd_from_file (std::string const &)
virtual void main (std::string)
booster::shared_ptr< json_callrelease_call ()
 json_rpc_server (cppcms::service &srv)
std::string method ()
bool notification ()
json::array const & params ()
void return_result (json::value const &)
void return_error (json::value const &)

Detailed Description

JSON-RPC service application.

User is expected to derive his own objects from this class in order to implement Json-RPC calls similarly to how cppcms::application is used.


Member Typedef Documentation

typedef booster::function<void(json::array const &)> cppcms::rpc::json_rpc_server::method_type

Generic type of JSON-RPC method


Member Enumeration Documentation

The role of the method - receives notification, returns result or any one of them

Enumerator:
any_role 

Method may receive notification and return result.

method_role 

Method can't be used with notification calls.

notification_role 

Method should be used with notification calls only.


Member Function Documentation

void cppcms::rpc::json_rpc_server::bind ( std::string const &  name,
method_type const &  ,
role_type  type = any_role 
)

Bind method JSON-RPC method with name name

virtual void cppcms::rpc::json_rpc_server::main ( std::string  ) [virtual]

Main function that dispatches JSON-RPC service calls

Reimplemented from cppcms::application.

Get the name of method that was called

Check if method call is notification only. You should not return a value.

Note: if you do not add restriction when binding json-rpc method on the role of the call you should always check this value. Otherwise trying to call return_result or return_error would throw.

Get call parameters as json::array (vector of json::value)

Release json_call for asynchronous responses. Calls release_context() and assignes it to json_call object.

Complete method response with a error. Throws call_error if the method was called as notification

Complete method response with a result. Throws call_error if the method was called as notification

Specify service SMD

void cppcms::rpc::json_rpc_server::smd_from_file ( std::string const &  )

Take service SMD as raw text from file

void cppcms::rpc::json_rpc_server::smd_raw ( std::string const &  )

Specify service SMD as raw text rather then JSON value


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