WsOverH2ServerStream
struct WsOverH2ServerStreamStream-keyed server adapter turning one h2 stream into a WS tunnel.
The RFC 6455 rules live in :class:flare.ws.protocol.WsProtocol; this
carrier moves its bytes. Outbound frames are unmasked (RFC 6455 5.3)
and go out through :meth:Http2Connection.queue_stream_data as far
as the stream's send window allows; the rest waits in the protocol's
bounded outbox.
Implements Copyable, Movable
- Fields
stream_id: Intproto: WsProtocolclosed: Bool
__init__
def __init__(out self, stream_id: Int) flush
def flush(mut self, mut conn: Http2Connection) -> Int Push queued outbound bytes as far as the window allows; return how many are still waiting.
send_frame
def send_frame(mut self, mut conn: Http2Connection, frame: WsFrame) Queue frame UNMASKED as DATA on this stream. A CLOSE ends the tunnel (later sends raise), and so does a send that would take the outbox past its bound (closed with 1008).
try_pull_frame
def try_pull_frame(mut self, mut conn: Http2Connection) -> Optional[WsFrame] Drain inbound DATA and return the next complete message as one TEXT or BINARY frame, a CLOSE frame once the session has ended (by the peer, or by a protocol violation answered with its CLOSE code), or None until more data arrives. PING, PONG and the CLOSE reply are handled here.
is_closed
def is_closed(self) -> Bool close
def close(mut self, mut conn: Http2Connection, code: UInt16 = UInt16(1000), reason: String = "") Send a server CLOSE frame (unmasked) to complete the handshake.