|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
Minimal async WebSocket (RFC 6455) client on asio coroutines. More...
#include <neograph/api.h>#include <asio/any_io_executor.hpp>#include <asio/awaitable.hpp>#include <cstdint>#include <memory>#include <optional>#include <string>#include <string_view>#include <utility>#include <vector>Go to the source code of this file.
Classes | |
| class | neograph::async::WsClient |
| Async WebSocket client. More... | |
Functions | |
| NEOGRAPH_API asio::awaitable< std::unique_ptr< WsClient > > | neograph::async::ws_connect (asio::any_io_executor ex, std::string_view host, std::string_view port, std::string_view path, std::vector< std::pair< std::string, std::string > > headers={}, bool tls=true) |
| Establish a WebSocket connection. | |
Minimal async WebSocket (RFC 6455) client on asio coroutines.
Phase A primitive — transport only, no protocol-specific framing above RFC 6455. Target use: OpenAI Responses WebSocket mode (wss://api.openai.com/v1/responses), but the client is generic: any wss:// or ws:// endpoint that speaks vanilla RFC 6455.
Scope covered:
Scope NOT covered (deliberate — keep the primitive lean):
Threading: a WsClient instance is NOT thread-safe. Run all send/recv on the same executor. Concurrent send + recv on the same instance is also unsafe — serialize at the caller.
Definition in file ws_client.h.
| NEOGRAPH_API asio::awaitable< std::unique_ptr< WsClient > > neograph::async::ws_connect | ( | asio::any_io_executor | ex, |
| std::string_view | host, | ||
| std::string_view | port, | ||
| std::string_view | path, | ||
| std::vector< std::pair< std::string, std::string > > | headers = {}, |
||
| bool | tls = true |
||
| ) |
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, std::runtime_error if the server refuses the upgrade (non-101 status or bad Accept).
References neograph::async::ws_connect().
Referenced by neograph::async::ws_connect().