package async_websocket

  1. Overview
  2. Docs

Content_reassembler can process fragmented content from websocket frames and reassemble fragmented content into a contiguous buffer.

It maintains an internal buffer which is reused to avoid allocs (most of the time). The internal buffer doubles in size whenever needed to avoid quadratic operations.

This can be used together with Frame.Frame_reader to implement the reader side of a websocket connection.

type t
val create : content_handler:((Core.read, Iobuf.no_seek) Iobuf.t -> unit) -> ping_handler:(content:(Core.read, Iobuf.no_seek) Iobuf.t -> unit) -> close_handler: (code:Connection_close_reason.t -> reason:string -> partial_content:string option -> unit) -> protocol_error_handler: (reason:string -> partial_content:string option -> frame:Frame.t option -> unit) -> ?initial_buffer_size:int -> unit -> t
val process_frame : t -> opcode:Opcode.t -> final:bool -> content:(Core.read, Iobuf.no_seek) Iobuf.t -> unit
val partial_content_string : t -> string option

partial_content_string yields the content of the contents of the most recent (yet unfinished) message, if there is any content.