mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-21 22:56:46 +01:00
Expand WebSocket example to match
on Message
(#723)
This commit is contained in:
parent
32c9ab3c56
commit
c0473f2b6f
1 changed files with 18 additions and 1 deletions
|
@ -75,7 +75,24 @@ async fn ws_handler(
|
|||
async fn handle_socket(mut socket: WebSocket) {
|
||||
if let Some(msg) = socket.recv().await {
|
||||
if let Ok(msg) = msg {
|
||||
println!("Client says: {:?}", msg);
|
||||
match msg {
|
||||
Message::Text(t) => {
|
||||
println!("client send str: {:?}", t);
|
||||
}
|
||||
Message::Binary(_) => {
|
||||
println!("client send binary data");
|
||||
}
|
||||
Message::Ping(_) => {
|
||||
println!("socket ping");
|
||||
}
|
||||
Message::Pong(_) => {
|
||||
println!("socket pong");
|
||||
}
|
||||
Message::Close(_) => {
|
||||
println!("client disconnected");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!("client disconnected");
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue