rustic-io

rustic-io is a simple websocket server library written in Rust. It aims to be an easy to implement, fast, and concurrent websocket server library for text and binary messages.

TODOs

Example Usage

```rust

[deriving(Decodable, Encodable)]

pub struct Foo { msg: String }

fn main() { let mut server = rusticio::newserver("127.0.0.1", "1338"); server.on("telljustme", telljustme); server.on("tellerrybody", tellerrybody); rustic_io::start(server); }

fn telljustme(data: json::Json, socket: Socket) { let jsonobject = data.asobject().unwrap(); let msg = jsonobject.get(&String::fromstr("msg")).unwrap().asstring().unwrap(); socket.send("echo", json::encode(&Foo { msg: String::fromstr(msg) })); }

fn tellerrybody(data: json::Json, socket: Socket) { let jsonobject = data.asobject().unwrap(); let msg = jsonobject.get(&String::fromstr("msg")).unwrap().asstring().unwrap(); socket.broadcast("echo", json::encode(&Foo { msg: String::fromstr(msg) })); } ```

Example Projects

Credits

WebSocket payload implementation from rust-ws