Mint.WebSocket.new

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

new(conn, request_ref, status, response_headers, opts \\ [])

View Source

Creates a new WebSocket data structure given the server's reply to the upgrade request

This function will setup any extensions accepted by the server using the Mint.WebSocket.Extension.init/2 callback.

Options

  • :mode - (default: :active) either :active or :passive. This corresponds to the same option in Mint.HTTP.connect/4.

Examples

http_reply = receive(do: (message -> message))
{:ok, conn, [{:status, ^ref, status}, {:headers, ^ref, headers}, {:done, ^ref}]} =
  Mint.WebSocket.stream(conn, http_reply)

{:ok, conn, websocket} =
  Mint.WebSocket.new(:ws, conn, ref, status, resp_headers)