Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::runtime::JsonRpcPeer Class Reference

#include <json_rpc.hpp>

Public Member Functions

 JsonRpcPeer (MessageChannel &channel)
 Wrap a message channel.
 ~JsonRpcPeer ()
 JsonRpcPeer (const JsonRpcPeer &)=delete
JsonRpcPeer & operator= (const JsonRpcPeer &)=delete
void register_method (std::string_view name, JsonRpcMethodHandler handler)
 Register a method handler.
void on_notification (std::string_view name, JsonRpcNotificationHandler handler)
 Register a notification handler.
bool send_request (std::string_view method, std::string_view params_json, JsonRpcResponseCallback callback)
 Send a request.
bool notify (std::string_view method, std::string_view params_json)
 Emit a notification.

Constructor & Destructor Documentation

◆ JsonRpcPeer() [1/2]

pulp::runtime::JsonRpcPeer::JsonRpcPeer ( MessageChannel & channel)
explicit

Wrap a message channel.

The peer installs an on_message handler on the channel; do not replace it after construction.

◆ ~JsonRpcPeer()

pulp::runtime::JsonRpcPeer::~JsonRpcPeer ( )

◆ JsonRpcPeer() [2/2]

pulp::runtime::JsonRpcPeer::JsonRpcPeer ( const JsonRpcPeer & )
delete

Member Function Documentation

◆ notify()

bool pulp::runtime::JsonRpcPeer::notify ( std::string_view method,
std::string_view params_json )

Emit a notification.

◆ on_notification()

void pulp::runtime::JsonRpcPeer::on_notification ( std::string_view name,
JsonRpcNotificationHandler handler )

Register a notification handler.

◆ operator=()

JsonRpcPeer & pulp::runtime::JsonRpcPeer::operator= ( const JsonRpcPeer & )
delete

◆ register_method()

void pulp::runtime::JsonRpcPeer::register_method ( std::string_view name,
JsonRpcMethodHandler handler )

Register a method handler.

Replacing a handler with nullptr unregisters.

◆ send_request()

bool pulp::runtime::JsonRpcPeer::send_request ( std::string_view method,
std::string_view params_json,
JsonRpcResponseCallback callback )

Send a request.

params_json must be a JSON-encoded array or object (or empty for no params). The callback fires exactly once with the response. Returns false if the channel is closed.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/runtime/include/pulp/runtime/json_rpc.hpp