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 event based messaging.

There was thought on binary support to match the protocol, but if that was supported, there would not be a way to parse functionality on event, because the message can either be text or binary. There is no mixing of the two. Currently, Vec is supported in JSON ecoding/decoding through Rust, so all "binary" data should be passed as a buffer in your message struct.

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("someevent", functiontoexecute); rusticio::start(server); }

fn functiontoexecute(data: json::Json, socket: Socket) { let jsonobject = data.asobject().unwrap();

// Do some stuff with received data...

// Create some object to send back
let bar = Foo {
    msg: String::from_str("Hello from Rust!")
};

// Send some event back to socket
socket.send("some_event", json::encode(&bar));

// Or, broadcast that event to all sockets
socket.broadcast("some_event", json::encode(&bar));

} ```

Example Projects

Credits

WebSocket payload implementation from rust-ws