View Source WsClient (WsClient v0.3.0)
Summary
Functions
Sets the callback function that gets called with the received data from the connected web socket.
Starts websocat
and connect to the given url.
Disconnects and stops the underlying websocat
connection and application.
Returns :ok
.
Send a message to the connected web server via the client. The server's respose will call the provided callback function.
Functions
Sets the callback function that gets called with the received data from the connected web socket.
Examples
iex> cb = fn data -> data |> IO.inspect end
#<Function<...>
iex> WsClient.callback(DocuClient, cb)
:ok
Starts websocat
and connect to the given url.
Returns :ok
or {:error, "Already connected"}
.
Examples
iex> WsClient.connect(DocuClient, "wss://echo.websocket.org")
{:error, "Already connected"}
iex> WsClient.disconnect(DocuClient)
:ok
iex> WsClient.connect(DocuClient, "wss://echo.websocket.org")
:ok
Disconnects and stops the underlying websocat
connection and application.
Returns :ok
.
Examples
iex> WsClient.disconnect(DocuClient)
:ok
Send a message to the connected web server via the client. The server's respose will call the provided callback function.
Make sure to include a newline '\n' character to submit the request.
Returns :ok
.
Examples
iex> WsClient.send(DocuClient, "hello world\n")
:ok