tube v0.1.1 Tube.Websocket
Represents a WebSocket connection
This GenServer will handle the whole lifecycle of one WebSocket connection.
Setup
{:ok, pid} = GenServer.start_link(Tube.Websocket,
uri: "ws://localhost:4000/ws",
opts: [parent: self])
:ok = Tube.Websocket.connect(pid)
This will open a WebSocket connection to ws://localhost:4000/ws
.
Incoming frames will be sent via message passing to the pid given in opts.parent
.
Messages to parent
{:websocket, :frame, frame}
{:websocket, :open}
{:websocket, :closed}
Summary
Functions
Specs
close(pid :: pid) :: :ok
Closes the connection by sending a close frame to the server.
Specs
send_frame(frame :: map, socket :: map) :: :ok
Sends a frame to the server
Specs
set_uri(pid :: pid, uri :: string) :: :ok
Changes the uri that will be used the next time connect/1
is called.