CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | List of all members
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:

## 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_call > | release_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 &)
Public Member Functions inherited from cppcms::application
| application (cppcms::service &srv)
virtual | ~application ()
cppcms::service & | service ()
json::value const & | settings ()
http::context & | context ()
http::request & | request ()
http::response & | response ()
url_dispatcher & | dispatcher ()
url_mapper & | mapper ()
cache_interface & | cache ()
session_interface & | session ()
void | render (std::string template_name, base_content &content)
void | render (std::string skin, std::string template_name, base_content &content)
void | render (std::string template_name, std::ostream &out, base_content &content)
void | render (std::string skin, std::string template_name, std::ostream &out, base_content &content)
void | add (application &app)
void | add (application &app, std::string const &regex, int part)
void | add (application &app, std::string const &name, std::string const &url, std::string const &regex, int part)
void | add (application &app, std::string const &name, std::string const &url)
void | attach (application *app)
void | attach (application *app, std::string const &regex, int part)
void | attach (application *app, std::string const &name, std::string const &url)
void | attach (application *app, std::string const &name, std::string const &url, std::string const &regex, int part)
application * | parent ()
application * | root ()
booster::shared_ptr< http::context > | release_context ()
booster::shared_ptr< http::context > | get_context ()
void | assign_context (booster::shared_ptr< http::context > conn)
void | add_context (http::context &conn)
void | remove_context ()
bool | is_asynchronous ()
bool | has_context ()
bool | owns_context ()
virtual void | init ()
virtual void | clear ()
std::string | translate (char const *context, char const *message)
std::string | translate (char const *message)
std::string | translate (char const *context, char const *single, char const *plural, int n)
std::string | translate (char const *single, char const *plural, int n)
std::string | url (std::string const &key)
std::string | url (std::string const &key, filters::streamable const &p1)
std::string | url (std::string const &key, filters::streamable const &p1, filters::streamable const &p2)
std::string | url (std::string const &key, filters::streamable const &p1, filters::streamable const &p2, filters::streamable const &p3)
std::string | url (std::string const &key, filters::streamable const &p1, filters::streamable const &p2, filters::streamable const &p3, filters::streamable const &p4)
std::string | url (std::string const &key, filters::streamable const &p1, filters::streamable const &p2, filters::streamable const &p3, filters::streamable const &p4, filters::streamable const &p5)
std::string | url (std::string const &key, filters::streamable const &p1, filters::streamable const &p2, filters::streamable const &p3, filters::streamable const &p4, filters::streamable const &p5, filters::streamable const &p6)

## 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

enum cppcms::rpc::json_rpc_server::role_type

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.

std::string cppcms::rpc::json_rpc_server::method | ( |  | ) |

Get the name of method that was called

bool cppcms::rpc::json_rpc_server::notification | ( |  | ) |

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.

json::array const& cppcms::rpc::json_rpc_server::params | ( |  | ) |

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

booster::shared_ptr<json_call> cppcms::rpc::json_rpc_server::release_call | ( |  | ) |

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

void cppcms::rpc::json_rpc_server::return_error | ( | json::value const & |  | ) |

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

void cppcms::rpc::json_rpc_server::return_result | ( | json::value const & |  | ) |

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

void cppcms::rpc::json_rpc_server::smd | ( | json::value const & |  | ) |

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:

- cppcms/rpc_json.h