View Source Wind.Client behaviour (wind v0.3.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
Summary
Callbacks
Invoked after a connection is established. Override to setup post-connection state.
Invoked for each received frame.
Types
@type frame() :: Mint.WebSocket.shorthand_frame() | Mint.WebSocket.frame()
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.
@callback handle_frame(frame :: frame(), state :: term()) :: {:reply, frame :: frame(), new_state :: term()} | {:noreply, new_state :: term()}
Invoked for each received frame.