Upgrade tokio-tungstenite to 0.26 (#3078)

This commit is contained in:
Lena
2024-12-18 15:15:55 -05:00
committed by GitHub
parent 5cdd8a4f18
commit 96e071c8fb
9 changed files with 194 additions and 58 deletions
+6 -4
View File
@@ -12,9 +12,9 @@
use futures_util::stream::FuturesUnordered;
use futures_util::{SinkExt, StreamExt};
use std::borrow::Cow;
use std::ops::ControlFlow;
use std::time::Instant;
use tokio_tungstenite::tungstenite::Utf8Bytes;
// we will use tungstenite for websocket client impl (same library as what axum is using)
use tokio_tungstenite::{
@@ -65,7 +65,9 @@ async fn spawn_client(who: usize) {
//we can ping the server for start
sender
.send(Message::Ping("Hello, Server!".into()))
.send(Message::Ping(axum::body::Bytes::from_static(
b"Hello, Server!",
)))
.await
.expect("Can not send!");
@@ -74,7 +76,7 @@ async fn spawn_client(who: usize) {
for i in 1..30 {
// In any websocket error, break loop.
if sender
.send(Message::Text(format!("Message number {i}...")))
.send(Message::Text(format!("Message number {i}...").into()))
.await
.is_err()
{
@@ -90,7 +92,7 @@ async fn spawn_client(who: usize) {
if let Err(e) = sender
.send(Message::Close(Some(CloseFrame {
code: CloseCode::Normal,
reason: Cow::from("Goodbye"),
reason: Utf8Bytes::from_static("Goodbye"),
})))
.await
{