Mint.WebSocket.stream

You're seeing just the function stream, go back to Mint.WebSocket module for more information.

Specs

stream(Mint.HTTP.t(), term()) ::
  {:ok, Mint.HTTP.t(), [Mint.Types.response()]}
  | {:error, Mint.HTTP.t(), Mint.Types.error(), [Mint.Types.response()]}
  | :unknown

A wrapper around Mint.HTTP.stream/2 for streaming HTTP and WebSocket messages

This function does not decode WebSocket frames. Instead, once a WebSocket connection has been established, decode any {:data, request_ref, data} frames with decode/2.

This function is a drop-in replacement for Mint.HTTP.stream/2 which enables streaming WebSocket data after the bootstrapping HTTP/1 connection has concluded. It decodes both WebSocket and regular HTTP messages.

Examples

message = receive(do: (message -> message))
{:ok, conn, [{:data, ^websocket_ref, data}]} =
  Mint.WebSocket.stream(conn, message)
{:ok, websocket, [{:text, "hello world!"}]} =
  Mint.WebSocket.decode(websocket, data)