package miaou-driver-web

  1. Overview
  2. Docs

Module Miaou_driver_web.Web_websocketSource

Minimal WebSocket implementation for Eio.

Implements RFC 6455 WebSocket protocol using direct flow writes (no Buf_write buffering).

Sourcetype t

A WebSocket connection.

Sourceval parse_headers : Eio.Buf_read.t -> (string, string) Hashtbl.t

Parse HTTP headers from a buffered reader until a blank line. Returns a hashtable of lowercase header names to values.

Sourceval upgrade : (string, string) Hashtbl.t -> write:(string -> unit) -> t option

Attempt a WebSocket upgrade given parsed HTTP headers. Sends the 101 Switching Protocols response via the write function. Returns None if the headers are not a valid upgrade request.

Sourceval send_text : t -> string -> unit

Send a text frame.

Sourceval recv_text : t -> Eio.Buf_read.t -> string option

Receive the next text message. Handles ping/pong automatically. Returns None on connection close.

Sourceval close : t -> unit

Send a close frame and shut down.

Sourceval is_closed : t -> bool

Check whether the connection has been closed.