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:
Grzegorz Baranski
2021-08-07 19:47:22 +02:00
committed by GitHub
parent ab927033b3
commit 4792d0c15c
4 changed files with 128 additions and 129 deletions
+5 -1
View File
@@ -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;
}