|
NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
|
Async WebSocket client. More...
#include <ws_client.h>
Public Member Functions | |
| asio::awaitable< WsMessage > | recv () |
| Block until the next application message arrives. | |
| asio::awaitable< void > | send_binary (std::string_view payload) |
| Send a binary frame (FIN=1). | |
| asio::awaitable< void > | send_close (std::uint16_t code=1000, std::string_view reason="") |
| Send a close frame with the given status code and optional UTF-8 reason. | |
| asio::awaitable< void > | send_text (std::string_view payload) |
| Send a text frame (FIN=1, no fragmentation). | |
Friends | |
| NEOGRAPH_API asio::awaitable< std::unique_ptr< WsClient > > | ws_connect (asio::any_io_executor, std::string_view, std::string_view, std::string_view, std::vector< std::pair< std::string, std::string > >, bool) |
| Establish a WebSocket connection. | |
| NEOGRAPH_API asio::awaitable< std::unique_ptr< WsClient > > | ws_connect (asio::any_io_executor, std::string_view, std::string_view, std::string_view, std::vector< std::pair< std::string, std::string > >, bool, WsClientOptions) |
| Establish a WebSocket connection with explicit resource ceilings. | |
Async WebSocket client.
Obtain via ws_connect; use send_* / recv on the returned instance. Destruction closes the socket unconditionally (no graceful close unless you called send_close first).
Definition at line 104 of file ws_client.h.
| asio::awaitable< WsMessage > neograph::async::WsClient::recv | ( | ) |
Block until the next application message arrives.
Pings are auto-replied with pongs and consumed; close frames are echoed back and surfaced to the caller as op==Close (after which the connection is no longer usable).
Throws asio::system_error on transport failure (asio::error::timed_out after WsClientOptions::read_timeout) or std::runtime_error on malformed frames (reserved bits set, masked server-to-client frame, unknown opcode).
| asio::awaitable< void > neograph::async::WsClient::send_binary | ( | std::string_view | payload | ) |
Send a binary frame (FIN=1).
Masked per §5.3. The payload is copied before the returned awaitable is exposed.
| asio::awaitable< void > neograph::async::WsClient::send_close | ( | std::uint16_t | code = 1000, |
| std::string_view | reason = "" |
||
| ) |
Send a close frame with the given status code and optional UTF-8 reason.
After send_close the caller should drain recv() until it returns an op==Close frame (peer echo), then let the destructor close the socket. Calling send_close twice is a no-op.
| asio::awaitable< void > neograph::async::WsClient::send_text | ( | std::string_view | payload | ) |
Send a text frame (FIN=1, no fragmentation).
Payload must be valid UTF-8 per RFC 6455 §5.6 — this client does NOT validate; the caller is responsible. Masked per §5.3. The payload is copied before the returned awaitable is exposed.
|
friend |
Establish a WebSocket connection.
| ex | Executor hosting the connection. |
| host | Target host (SNI + Host header + cert verification). |
| port | Port string ("443", "80", etc.). |
| path | Origin-form path starting with '/'. Query string allowed; fragment not. |
| headers | Extra HTTP headers injected into the Upgrade request. Typical use: {"Authorization","Bearer sk-..."}. Do NOT set Upgrade/Connection/Sec-WebSocket-* here — the client sets those itself. |
| tls | Use wss:// (TLS) vs ws:// (plain TCP). |
Throws asio::system_error on transport failure (asio::error::timed_out after WsClientOptions::handshake_timeout, 30 s by default), std::runtime_error if the server refuses the upgrade (non-101 status or bad Accept). Request inputs are copied before the returned awaitable is exposed.
|
friend |
Establish a WebSocket connection with explicit resource ceilings.
Other parameters have the same semantics as the overload above.