JSON-RPC 2.0 server implementation over WebSocket.
More...
#include <json_rpc.hpp>
JSON-RPC 2.0 server implementation over WebSocket.
◆ JsonRpc() [1/3]
Constructs a new JSON-RPC server.
◆ ~JsonRpc()
| plotly::detail::JsonRpc::~JsonRpc |
( |
| ) |
|
Destructor. Stops the server if running.
◆ JsonRpc() [2/3]
| plotly::detail::JsonRpc::JsonRpc |
( |
const JsonRpc & | | ) |
|
|
delete |
◆ JsonRpc() [3/3]
| plotly::detail::JsonRpc::JsonRpc |
( |
JsonRpc && | other | ) |
|
|
noexcept |
◆ call()
| auto plotly::detail::JsonRpc::call |
( |
const std::string & | method, |
|
|
const nlohmann::json & | params ) -> std::pair<std::future<nlohmann::json>, std::function<void()>> |
Makes an asynchronous JSON-RPC call to the connected client.
- Parameters
-
| method | The name of the method to call. |
| params | The parameters to pass to the method. |
- Returns
- A pair containing a future containing the result of the RPC call and a function to cancel the call.
◆ getWebsocketEndpoint()
Gets a raw pointer to the underlying websocket endpoint.
- Returns
- Raw pointer to the websocket endpoint (for compatibility).
◆ notify()
| void plotly::detail::JsonRpc::notify |
( |
const std::string & | method, |
|
|
const nlohmann::json & | params ) |
Sends a notification to all connected clients.
- Parameters
-
| method | The name of the method to call. |
| params | The parameters to pass to the method. |
◆ operator=() [1/2]
| auto plotly::detail::JsonRpc::operator= |
( |
const JsonRpc & | | ) |
-> JsonRpc &=delete |
|
delete |
◆ operator=() [2/2]
| auto plotly::detail::JsonRpc::operator= |
( |
JsonRpc && | other | ) |
-> JsonRpc & |
|
noexcept |
◆ registerCallbackWithWebsocket()
| void plotly::detail::JsonRpc::registerCallbackWithWebsocket |
( |
const std::string & | callbackName, |
|
|
std::function< void(const std::string_view)> | callback ) |
Registers a callback function for the WebSocket endpoint.
- Parameters
-
| callbackName | The name of the callback to register. |
| callback | The callback function to be called when messages are received. |
◆ registerHandler()
| void plotly::detail::JsonRpc::registerHandler |
( |
const std::string & | method, |
|
|
const std::function< nlohmann::json(const nlohmann::json &)> & | handler ) |
Registers a handler function for a specific RPC method.
- Parameters
-
| method | The name of the RPC method. |
| handler | The handler function to be called when the method is invoked. |
◆ registerNotification()
| void plotly::detail::JsonRpc::registerNotification |
( |
const std::string & | method, |
|
|
std::function< void(const nlohmann::json &)> | handler ) |
◆ unregisterAllCallbacksFromWebsockets()
| void plotly::detail::JsonRpc::unregisterAllCallbacksFromWebsockets |
( |
| ) |
|
Unregisters all callbacks from the WebSocket endpoint.
◆ unregisterCallbackFromWebsocket()
| void plotly::detail::JsonRpc::unregisterCallbackFromWebsocket |
( |
const std::string & | callbackName | ) |
|
Unregisters a callback function from the WebSocket endpoint.
- Parameters
-
| callbackName | The name of the callback to unregister. |
◆ unregisterHandler()
| void plotly::detail::JsonRpc::unregisterHandler |
( |
const std::string & | method | ) |
|
The documentation for this class was generated from the following files: