View Source Wind (wind v0.1.0)

A pleasant Elixir websocket client library based on Mint.

Link to this section Summary

Functions

Statelessly connect to a websocket URL. This is a convenience function around Mint that establishes a connection to uri and then subsequently upgrades the connection.

Statelessly decode a websocket message. This is a convenience function that wraps Mint.WebSocket stream/2 and decode/2 functions.

Statelessly send a websocket message. This is a convenience function that wraps Mint.WebSocket the encode/2 and stream_request_body/3 functions.

Statelessly setup a websocket connection. This is a convenience function that wraps Mint.WebSocket the setup functions for a websocket.

Synchronously setup a websocket connection. See setup/3.

Link to this section Functions

Link to this function

connect(uri, headers \\ [], opts \\ [])

View Source
@spec connect(URI.t(), list(), list()) ::
  {:ok, Mint.HTTP.t(), Mint.Types.request_ref()}
  | {:error, Mint.Types.error()}
  | {:error, Mint.HTTP.t(), Mint.WebSocket.error()}

Statelessly connect to a websocket URL. This is a convenience function around Mint that establishes a connection to uri and then subsequently upgrades the connection.

examples

Examples

iex> URL.new!("wss://socketsbay.com/wss/v2/1/demo/") |> Wind.connect()
{:ok, conn, ref}
Link to this function

decode(conn, ref, websocket, message)

View Source

Statelessly decode a websocket message. This is a convenience function that wraps Mint.WebSocket stream/2 and decode/2 functions.

examples

Examples

iex> Wind.decode(conn, ref, websocket, message)
{:ok, conn, websocket, data}
Link to this function

send(conn, ref, websocket, message)

View Source

Statelessly send a websocket message. This is a convenience function that wraps Mint.WebSocket the encode/2 and stream_request_body/3 functions.

examples

Examples

iex> Wind.decode(conn, ref, websocket, message)
{:ok, conn, websocket}
Link to this function

setup(conn, ref, http_reply_message, opts \\ [])

View Source

Statelessly setup a websocket connection. This is a convenience function that wraps Mint.WebSocket the setup functions for a websocket.

examples

Examples

iex> Wind.setup(conn, ref, http_reply_message)
{:ok, conn, ref, websocket}

Synchronously setup a websocket connection. See setup/3.

examples

Examples

iex> Wind.setup_await(conn, ref)
{:ok, conn, ref, websocket}