mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-22 00:00:17 +02:00
Make ws::Message an enum for easier frame type matching (#116)
* feat(ws): make Message an enum to allow pattern matching * fix(examples): update to new websockets `Message` * fix(ws): remove wildcard imports * fix(examples/chat): apply clippy's never_loop * style: `cargo fmt` * docs:add license notes above parts that are copied * fix(ws): make CloseCode an alias to u16 * fix: move Message from src/ws/mod.rs to src/extract/ws.rs * docs: add changelog entry about websocket messages * fix: remove useless convertions to the same type
This commit is contained in:
@@ -84,7 +84,11 @@ async fn handle_socket(mut socket: WebSocket) {
|
||||
}
|
||||
|
||||
loop {
|
||||
if socket.send(Message::text("Hi!")).await.is_err() {
|
||||
if socket
|
||||
.send(Message::Text(String::from("Hi!")))
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
println!("client disconnected");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user