View Source Minch.Conn (Minch v0.1.0)

Minch WebSocket connection.

Summary

Functions

Gracefully closes the connection if it's still open.

Opens a new connection.

Send a frame via the connection.

Wraps Mint.WebSocket.stream/2 and decodes WebSocket frames.

Types

@type response() :: %{
  optional(:status) => Mint.Types.status(),
  optional(:headers) => Mint.Types.headers(),
  optional(:data) => binary(),
  optional(:error) => term(),
  optional(:frames) => [Mint.WebSocket.frame()]
}
@type t() :: %Minch.Conn{
  conn: Mint.HTTP.t(),
  request_ref: Mint.Types.request_ref(),
  websocket: Mint.WebSocket.t() | nil
}

Functions

@spec close(t()) :: t()

Gracefully closes the connection if it's still open.

Link to this function

open(url, headers \\ [], options \\ [])

View Source
@spec open(String.t() | URI.t(), Mint.Types.headers(), Keyword.t()) ::
  {:ok, t()} | {:error, Mint.WebSocket.error()}

Opens a new connection.

For the available options see Mint.HTTP.connect/4 and Mint.WebSocket.upgrade/5 functions.

Link to this function

open?(c, type \\ :read_write)

View Source

Wraps Mint.HTTP.open?/2.

@spec send_frame(t(), Mint.WebSocket.frame() | Mint.WebSocket.shorthand_frame()) ::
  {:ok, t()}
  | {:error, t(), Minch.Conn.NotUpgradedError.t() | Mint.Types.error() | term()}

Send a frame via the connection.

@spec stream(t(), term()) ::
  {:ok, t(), response()}
  | {:error, t(),
     Mint.Types.error()
     | Mint.WebSocketError.t()
     | Minch.Conn.UpgradeFailureError.t()}
  | :unknown

Wraps Mint.WebSocket.stream/2 and decodes WebSocket frames.