15#include <nlohmann/json.hpp>
19#include <dfx-utilities/FileSystem.hpp>
Macros to implement the Private State (PIMPL-like) idiom with value semantics.
#define DFX_PRIVATE_STATE(Class, logger)
Declare a private implementation state for a class.
Definition PrivateState.hpp:52
#define DFX_PRIVATE_STATE_DECLARE_RULE_OF_5(Class)
Declare Rule-of-5 special member functions using the private state pattern.
Definition PrivateState.hpp:82
Wrapper around a JSON message returned by the client protocol/API.
Definition Message.hpp:38
void disconnect()
Disconnect from the server and release underlying resources. If willAutoReconnect() returns true then...
void setAutoReconnect(bool shouldReconnect)
Enable or disable automatic reconnection.
bool willAutoReconnect() const noexcept
Return whether the client will automatically attempt to reconnect.
bool isConnected() const noexcept
Check whether the client is currently connected.
std::move_only_function< void(Message)> Callback
Callback type used to deliver a received message or a response.
Definition SocketClient.hpp:52
void reconnect()
Attempt to (re)establish the connection. Previous connection (if any) will be closed if this function...
SocketClient(FdWatch::Poller &poller, fs::path socketPath, int version=1)
Construct a socket client bound to a poller.
std::string sendCommand(std::string_view cmd, nlohmann::json const ¶ms, Callback cb=nullptr, std::string_view id={})
Send a request/command to the server.
void setMessageCallback(Callback cb)
Set the callback invoked for incoming messages.
void sendNotification(nlohmann::json json)
Send a one-way notification to the server.
static std::string generateRequestId()
Generate a new request identifier.
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
Definition Message.hpp:21
Definition SocketClient.hpp:23