Skip to content

Rust Websocket Server Example w/ De/Serialization, Async/Await, Arg Parsing and Logging.

License

Notifications You must be signed in to change notification settings

serg06/rust-full-websocket-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 13, 2022
568de99 · Feb 13, 2022

History

10 Commits
Feb 13, 2022
Feb 13, 2022
Feb 13, 2022
Feb 13, 2022
Feb 13, 2022
Feb 13, 2022
Feb 13, 2022

Repository files navigation

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:

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:

About

Rust Websocket Server Example w/ De/Serialization, Async/Await, Arg Parsing and Logging.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published