An Elixir Websocket Client.
A simple implemenation would be
defmodule WebSocketExample do
use WebSockex
def start_link(url, state) do
WebSockex.start_link(url, __MODULE__, state)
end
def handle_frame({type, msg}, state) do
IO.puts "Received Message - Type: #{inspect type} -- Message: #{inspect msg}"
{:ok, state}
end
end
See the examples/
directory for other examples or take a look at the documentation.
- Add
websockex
to your list of dependencies inmix.exs
:
def deps do
[{:websockex, "~> 0.3.0"}]
end
- Ensure
websockex
is started before your application:
def application do
[applications: [:websockex]]
end