Skip to content
A websocket client in erlang
Find file
Pull request Compare This branch is 49 commits behind madtrick:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src
test/acceptance
.gitignore
Guardfile
LICENSE
README.md
Rakefile
espec
rebar.config

README.md

wsecli

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 : )

Features

Supported protocol versions

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

Callbacks for the events: on_open, on_error, on_message and on_close can be added. Check the code or the documentation for details.

Tests

Unit tests

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/

TODO

  • 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)

License

Licensed under Apache 2.0. Check LICENSE for details

Contribute

If you find or think that something isn't working properly, just open an issue.

Pull requests and patches (with tests) are welcome.

Something went wrong with that request. Please try again.