W3WS.Handler behaviour (w3ws v0.2.0)
Base module for W3WS handlers
W3WS.Env
, W3WS.Event
and W3WS.RawEvent
are aliased into your handler
automatically when you use W3WS.Handler
.
Define the handle_event/1
function to handle events in your handler. Events are not
retried on error so be sure you have any necessary error handling or retry logic in place
if you cannot miss any events.
Example
defmodule MyHandler do
use W3WS.Handler
@impl W3WS.Handler
def handle_event(%Env{decoded?: true, event: %Event{} = event}) do
# inspect decoded events
IO.inspect(event)
end
def handle_event(_env) do
# ignore non-decoded events
:ok
end
end
Summary
Callbacks
Callback invoked for each received event
Types
Callbacks
Link to this callback
handle_event(t)
@callback handle_event(W3WS.Env.t()) :: any()
Callback invoked for each received event