WebSockex
An Elixir Websocket Client.
The client itself is provided through the WebSockex.Client module.
The simplest implemenation is
defmodule WebSocketExample do
use WebSockex.Client
def start_link(url, state) do
WebSockex.Client.start_link(url, __MODULE__, state)
end
def handle_frame({type, msg}, state) do
IO.puts "Recieved Message - Type: #{inspect type} -- Message: #{inspect msg}"
end
end
See the examples/ directory for other examples or take a look at the documentation.
Installation
- Add
websockexto your list of dependencies inmix.exs:
def deps do
[{:websockex, "~> 0.1.1"}]
end
- Ensure
websockexis started before your application:
def application do
[applications: [:websockex]]
end