A WebSocket client written in Erlang
This project was born as a side project while I'm doing my end of dregree project. What this means is:
- I don't have too much time to include new features.
But,
- I'll try to fix any bugs.
- I'll try to finish anything on the TODO.
- If anyone suggests something interesting/cool, I'll try to include it : )
- Built using wsock
Currently only the version specificied at RFC6455 (version 13) is supported.
Please notice that currently, neither subprotocols nor extensions are currently available.
Build ###
Add this repo as a dependency to your rebar.config file and then
rebar compile
Usage ###
I will demostrate its usage with the echo service at www.websocket.org.
Start it,
1>wsecli:start("echo.websocket.org", 80, "/").
Add a callback for received messages,
2>wsecli:on_message(fun(text, Message)-> io:format("Echoed message: ~s ~n", [Message]) end).
Send a message that will be echoed,
3> wsecli:send("Hello").
ok
Echoed message: Hello
And finally to stop it
4>wsecli:stop().
Callbacks for the events: on_open, on_error, on_message and on_close can be added. Check the code or the documentation for details.
Unit test where done with the library espec by lucaspiller.
To run them
rake spec
or, in case you don't have rake installed,
rebar compile && ERL_LIBS='deps/' ./espec test/spec/
- Accept WebSocket uris (those with ws:// format).
- Support streaming (not sure how to do this).
- Support ssl.
- Creation on multiple clients (too lazy, that's why I haven't done it already)
Licensed under Apache 2.0. Check LICENSE for details
If you find or think that something isn't working properly, just open an issue.
Pull requests and patches (with tests) are welcome.