Rust Full Websocket Example This is a boilerplate Rust Websocket Server with: socket.io-like message format: { "event": "SOME_EVENT_NAME", "data"?: <ARBITRARY_DATA> } JSON serialization / deserialization to / from structs with serde and serde_json See msg_in.rs for a list of all incoming events async / await event handlers with tokio-tungstenite argument parsing with clap logging with log and env_logger To run: cargo run To test: Open a new tab in Chrome Copy-paste the code from test-server.js To modify: Add your own incoming and outgoing messages to msg_in.rs and msg_out.rs respectively Add your own message handlers to src/handler Register message handlers in main.rs::handle_event Add args in args.rs Misc: This was based off of autobahn-server. This code can be slightly modified to become a CLIENT instead of a SERVER. See autobahn-client.