27 explicit Server(std::unique_ptr<transport::Transport> transport);
58 [[nodiscard]]
auto IsRunning()
const -> bool;
65 std::unique_ptr<Dispatcher> dispatcher_;
68 std::unique_ptr<transport::Transport> transport_;
71 std::atomic<bool> running_{
false};
A JSON-RPC server for handling requests and notifications.
void Start()
Starts the server to handle incoming JSON-RPC requests.
auto IsRunning() const -> bool
Checks if the server is currently running.
void RegisterMethodCall(const std::string &method, const MethodCallHandler &handler)
Registers an RPC method handler with the dispatcher.
void RegisterNotification(const std::string &method, const NotificationHandler &handler)
Registers an RPC notification handler with the dispatcher.
Server(std::unique_ptr< transport::Transport > transport)
Constructs a Server with the specified transport.
void Stop()
Stops the server from handling requests.
std::function< void(const std::optional< nlohmann::json > &)> NotificationHandler
Type alias for notification handler functions.
std::function< nlohmann::json(const std::optional< nlohmann::json > &)> MethodCallHandler
Type alias for method call handler functions.