View Source Wind.Client behaviour (wind v0.2.1)

Client is the basis for creating a connection module in your application.

  defmodule Example do
    use Wind.Client

    def start_link() do
      uri = URI.new!("http://example.com/ws")
      Wind.Client.start_link(__MODULE__, uri: uri)
    end

    def handle_connect(state) do
      # Handle any post-connect setup here.
      {:noreply, state}
    end

    def handle_frame({type, message}, state) do
      IO.inspect({type, message}, label: "frame")
      {:noreply, state}
    end
  end

Link to this section Summary

Callbacks

Invoked after a connection is established. Override to setup post-connection state.

Invoked for each received frame.

Link to this section Types

Link to this section Callbacks

@callback handle_connect(state :: term()) ::
  {:reply, frame :: frame(), new_state :: term()}
  | {:noreply, new_state :: term()}

Invoked after a connection is established. Override to setup post-connection state.

Link to this callback

handle_frame(frame, state)

View Source
@callback handle_frame(frame :: frame(), state :: term()) ::
  {:reply, frame :: frame(), new_state :: term()}
  | {:noreply, new_state :: term()}

Invoked for each received frame.

Link to this section Functions

Link to this function

start_link(module, default, options \\ [])

View Source