|
cxxmcp 1.1.6
C++ MCP SDK
|
WebSocket-based MCP client transport. More...
#include <websocket_transport.hpp>
Public Member Functions | |
| WebSocketClientTransport (WebSocketClientTransportOptions options) | |
| Constructs a client transport with the given options. | |
| ~WebSocketClientTransport () override | |
| Stops the reader thread and closes the WebSocket connection. | |
| WebSocketClientTransport (const WebSocketClientTransport &)=delete | |
| WebSocketClientTransport & | operator= (const WebSocketClientTransport &)=delete |
| std::string_view | name () const noexcept override |
| Returns "websocket-client". | |
| protocol::Json | diagnostics () const override |
| Returns structured diagnostics including connection state and stats. | |
| core::Result< core::Unit > | send (TxMessage message) override |
| Sends a JSON-RPC message over the WebSocket connection. | |
| core::Result< std::optional< RxMessage > > | receive () override |
| Blocks until the next inbound JSON-RPC message is available. | |
| core::Result< core::Unit > | close () override |
| Closes the transport and unblocks any blocked receive(). | |
Public Member Functions inherited from mcp::transport::Transport< Role > | |
| virtual void | wait_until_ready () |
| Blocks until the transport is ready to process messages. | |
Additional Inherited Members | |
Public Types inherited from mcp::transport::Transport< Role > | |
| using | TxMessage = typename MessageTraits< Role >::TxMessage |
| using | RxMessage = typename MessageTraits< Role >::RxMessage |
WebSocket-based MCP client transport.
Provides a full-duplex JSON-RPC channel over WebSocket with built-in automatic reconnection using exponential backoff.
Thread safety: send() is safe to call from multiple threads. receive() is sequential and must not be called concurrently. close() is safe to call from any thread and will unblock a blocked receive().
|
explicit |
Constructs a client transport with the given options.
| options | Connection and reconnection configuration. |
|
overridevirtual |
Closes the transport and unblocks any blocked receive().
Implements mcp::transport::Transport< Role >.
|
overridevirtual |
Returns structured diagnostics including connection state and stats.
Reimplemented from mcp::transport::Transport< Role >.
|
overridevirtualnoexcept |
Returns "websocket-client".
Implements mcp::transport::Transport< Role >.
|
overridevirtual |
Blocks until the next inbound JSON-RPC message is available.
Returns std::nullopt when the transport is closed.
Implements mcp::transport::Transport< Role >.
|
overridevirtual |
Sends a JSON-RPC message over the WebSocket connection.
For requests, the response is delivered through receive() once the peer replies. If the connection is down and auto_reconnect is enabled, an immediate reconnection attempt is made before sending.
Implements mcp::transport::Transport< Role >.