package async_websocket

  1. Overview
  2. Docs
type t
val create : role:[ `Client of Core.Random.State.t | `Server ] -> t
val required_frame_bytes : t -> content_len:int -> int
val max_content_bytes : t -> max_frame_bytes:int -> int
val start_write : t -> (Core.read_write, Iobuf.seek) Iobuf.t -> opcode:Opcode.t -> final:bool -> content_len:int -> (Core.read_write, Iobuf.seek) Iobuf.t

Starts writing a frame to the given iobuf; and returns a "content window" iobuf pointing to websocket frame's content.

Caller must:

  • Provide an iobuf with at least required_frame_bytes space.
  • Advance/write exactly content_len bytes to the content window.
  • Invoke finish_write.
val finish_write_exn : t -> unit

Finishes writing a frame to the given iobuf. Raises if the iobuf still has a nonzero length.