Crates.io | webchaussette |
lib.rs | webchaussette |
version | 1.3.3 |
source | src |
created_at | 2024-04-23 20:45:04.433428 |
updated_at | 2024-04-25 20:05:11.777458 |
description | Fast, powerful, and easy-to-set-up WebSocket library |
homepage | |
repository | |
max_upload_size | |
id | 1218017 |
size | 42,581 |
To use this library, simply add it to your Cargo.toml
:
[dependencies]
webchaussette = "1.0"
async-trait = "0.1"
tokio = "1"
use webchaussette::server::{EventHandler, Public, Server, Types};
// Implement the field if you wish
struct Test;
#[async_trait::async_trait]
impl EventHandler for Test {
// Read incoming user data
async fn on_message(&self, public: &mut Public) {
match &public.message {
Types::String(val) => println!("{}", val),
Types::Binary(val) => println!("{:?}", val),
}
}
async fn on_close(&self) {
println!("The user has left");
}
}
#[tokio::main]
async fn main() {
let mut server: Server = Server::new("0.0.0.0:8080").await;
server.set_handler(Box::new(Test));
server.run().await;
}
Documentation is being processed !
Contributions are welcome! Feel free to open issues or send pull requests.
This project is licensed under MIT. See the LICENSE file for more details