package websocket

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Module Websocket: websocket library for Lwt

This module implements a websocket client and server library in the spirit of the otherwise similar TCP functions of the Lwt_io module. The websocket protocol add message framing in addition of simple TCP communication, and this library implement framing and unframing of messages.

val section : Lwt_log_core.section
module Frame : sig ... end
val with_connection : ?extra_headers:Cohttp.Header.t -> ctx:Conduit_lwt_unix.ctx -> Conduit_lwt_unix.client -> Uri.t -> ((unit -> Frame.t Lwt.t) * (Frame.t -> unit Lwt.t)) Lwt.t
val establish_server : ?timeout:int -> ?stop:unit Lwt.t -> ctx:Conduit_lwt_unix.ctx -> mode:Conduit_lwt_unix.server -> (int -> Cohttp.Request.t -> (unit -> Frame.t Lwt.t) -> (Frame.t -> unit Lwt.t) -> unit Lwt.t) -> unit Lwt.t

Convenience functions

val mk_frame_stream : (unit -> Frame.t Lwt.t) -> Frame.t Lwt_stream.t

mk_frame_stream f is a stream build from f, which role is to receive the frames that will form the stream. When a Close frame is received, the stream will be closed.

val establish_standard_server : ?timeout:int -> ?stop:unit Lwt.t -> ctx:Conduit_lwt_unix.ctx -> mode:Conduit_lwt_unix.server -> (int -> Cohttp.Request.t -> (unit -> Frame.t Lwt.t) -> (Frame.t -> unit Lwt.t) -> unit Lwt.t) -> unit Lwt.t

establish_standard_server is like establish_server but with automatic handling of some frames:

  • A Pong frame is sent in response to a Ping frame,
  • a Close frame is sent in response to a Close frame.

All frames are then passed to the frame handling function.

OCaml

Innovation. Community. Security.