16#ifndef A11_NET_WEBSOCKET_WIRE_STREAM_H_
17#define A11_NET_WEBSOCKET_WIRE_STREAM_H_
24#include <absl/base/nullability.h>
25#include <absl/status/status.h>
26#include <absl/status/statusor.h>
61 struct ConstructorToken {};
74 static absl::StatusOr<std::shared_ptr<WebSocketWireStream>>
CreateClient(
82 static absl::StatusOr<std::shared_ptr<WebSocketWireStream>> CreateAccepted(
83 HttpRequest request, std::shared_ptr<Http2ResponseWriter> response,
111 std::function<
a11::Task(std::shared_ptr<WebSocketWireStream>)>;
121 :
public std::enable_shared_from_this<WebSocketWireServer> {
130 static absl::StatusOr<std::shared_ptr<WebSocketWireServer>>
Create(
137 absl::StatusOr<std::uint16_t>
port()
const;
147 : state_(std::move(state)) {}
149 std::shared_ptr<State> state_;
Shared WireStream lifecycle and framing for binary channels.
Definition channel_wire_stream.h:55
Accepts inbound WebSocket connections and hands each to a callback.
Definition websocket_wire_stream.h:121
bool running() const
Definition websocket_wire_stream.cc:259
absl::StatusOr< std::uint16_t > port() const
Definition websocket_wire_stream.cc:252
~WebSocketWireServer()
Definition websocket_wire_stream.cc:239
absl::Status Stop()
Stops the server and closes the listening socket.
Definition websocket_wire_stream.cc:243
void *absl_nullable GetImpl() const
Definition websocket_wire_stream.cc:264
static absl::StatusOr< std::shared_ptr< WebSocketWireServer > > Create(OnWebSocketStream on_stream, WebSocketServerOptions options={})
Starts a WebSocket server accepting A11 connections.
Definition websocket_wire_stream.cc:184
A WireStream that carries A11 traffic over a client or accepted WebSocket.
Definition websocket_wire_stream.h:59
WebSocketWireStream(ConstructorToken, std::shared_ptr< State > state)
Definition websocket_wire_stream.h:78
static absl::StatusOr< std::shared_ptr< WebSocketWireStream > > CreateClient(std::string url, WireStreamOptions options={}, WebSocketClientOptions websocket_options={})
Dials a WebSocket endpoint and returns a WireStream over it.
Definition websocket_wire_stream.cc:115
Completion values used by every asynchronous A11 operation.
A11's nghttp2 HTTP/2 client, server, and streaming primitives.
std::function< a11::Task(std::shared_ptr< WebSocketWireStream >)> OnWebSocketStream
Callback invoked with a fresh WireStream for each accepted connection.
Definition websocket_wire_stream.h:111
std::vector< std::pair< std::string, std::string > > HttpHeaders
An ordered list of (name, value) HTTP/2 header fields.
Definition http2.h:45
Future< Unit > Task
Asynchronous operation whose only successful result is completion itself.
Definition future.h:403
Future< T > SubmitWithCancellationHook(absl::AnyInvocable< absl::StatusOr< T >() && > work, std::function< void()> cancellation_hook, thread::TreeOptions tree_options)
Run work on A11's fiber pool with application-specific cancellation.
Definition executor.h:30
Packetisation and incomplete-message bounds for a binary WireStream.
Definition channel_wire_stream.h:32
Body-size limits, buffering thresholds, deadline, and TLS for an HTTP/2 client or server.
Definition http2.h:103
A parsed HTTP/2 request: pseudo-headers, fields, and body.
Definition http2.h:64
Client-side tuning for a WebSocketWireStream connection.
Definition websocket_wire_stream.h:42
HttpHeaders headers
Extra WebSocket handshake headers.
Definition websocket_wire_stream.h:44
absl::Status Validate() const
Definition websocket_wire_stream.cc:108
ChannelFramingOptions framing
Packet splitting and reassembly bounds.
Definition websocket_wire_stream.h:45
Http2Options http2_options
HTTP/2 connection and TLS policy.
Definition websocket_wire_stream.h:43
Listen address, path, and per-stream defaults for a WebSocketWireServer.
Definition websocket_wire_stream.h:97
std::uint16_t port
Listen port; zero requests an ephemeral port.
Definition websocket_wire_stream.h:100
std::string bind_address
Local listen address.
Definition websocket_wire_stream.h:99
ChannelFramingOptions framing
Framing for accepted streams.
Definition websocket_wire_stream.h:102
Http2Options http2_options
Server HTTP/2 and TLS policy.
Definition websocket_wire_stream.h:103
std::string path
WebSocket endpoint path.
Definition websocket_wire_stream.h:98
WireStreamOptions stream_options
Defaults for accepted streams.
Definition websocket_wire_stream.h:101
absl::Status Validate() const
Definition websocket_wire_stream.cc:158
Definition websocket_wire_stream.cc:172
Buffering, sizing, and deadline limits for a WireStream endpoint.
Definition wire_stream.h:44
A11's transport abstraction: the bidirectional WireStream channel and the options/callbacks that driv...