Receives a decoded message on the connection’s callback thread. Return true to consume it or false to leave it for receive(); the default returns false. The message reference is borrowed for the callback.
Installs a borrowed message delegate; nullptr selects the default. Replacement is synchronized with callbacks, and the delegate must remain alive while installed.
bool connect(const cstr& host, const cstr& path, int port = 443);
Connects using TLS and performs the WebSocket handshake. host is a hostname and path begins with /; returns false for invalid input, an already active connection, or connection failure.
Serializes a supported JSON value and sends it as a text frame. Calls outside the socket’s callback thread wait for the local write; calls from that thread enqueue without blocking. The input value is retained.
Retrieves a message not consumed by the delegate. Returns false for timeout or clean closure and rethrows asynchronous failures after queued messages drain; false leaves the output unchanged. Blocking receive is not allowed inside the socket’s own callback.