ANN: Salvo - An experimental websocket client and server

Hi all,

I just released Salvo, which contains both a websocker server and client. The server is based on cowboy and the client on gun.

The interesting part (IMHO) is that both the client and server have an Enumerable and Collectable implementation, so they play nice with streams. Here’s an example that pushes a file from the server to the client:

# node 1
iex> s = Salvo.Server.stream!("/websocket", 8080)

# node 2
iex> c = Salvo.Client.stream!("http://127.0.0.1:8080/websocket")
iex> Stream.into(c, File.stream!("README.bak")) |> Stream.run()

# node 1
iex> File.stream!("README.md") |> Stream.into(s) |> Stream.run()

# Tell the client to close it's connection
iex> Salvo.Server.send!(s, :close)

I wrote this library in a day, because I think websockets and Elixir streams could be an nice match, but we’ll see if that’s indeed the case. Don’t expect to use this for building the next WhatsApp, as this is just an experiment without any real world usage :slight_smile: However, I can see it being useful for ad hoc tasks and simple utilities.

I’d love to hear your opinion about the usefulness of this little library!

-vincent

5 Likes