1
1
use crate :: config:: GLOBAL_CONFIG ;
2
- use axum:: extract:: ws:: { self , WebSocket , WebSocketUpgrade } ;
2
+ use axum:: extract:: ws:: { self , Utf8Bytes as AxumUtf8Bytes , WebSocket , WebSocketUpgrade } ;
3
3
use axum:: response:: IntoResponse ;
4
4
use futures_util:: { SinkExt , StreamExt } ;
5
5
use tokio_tungstenite:: connect_async;
@@ -64,7 +64,7 @@ async fn handle_socket(mut tuono_socket: WebSocket) {
64
64
while let Some ( msg) = tuono_receiver. next ( ) . await {
65
65
if let Ok ( msg) = msg {
66
66
let msg_to_vite = match msg. clone ( ) {
67
- ws:: Message :: Text ( str) => Message :: Text ( str) ,
67
+ ws:: Message :: Text ( str) => Message :: Text ( str. to_string ( ) . into ( ) ) ,
68
68
ws:: Message :: Pong ( payload) => Message :: Pong ( payload) ,
69
69
ws:: Message :: Ping ( payload) => Message :: Ping ( payload) ,
70
70
ws:: Message :: Binary ( payload) => Message :: Binary ( payload) ,
@@ -91,7 +91,7 @@ async fn handle_socket(mut tuono_socket: WebSocket) {
91
91
tokio:: spawn ( async move {
92
92
while let Some ( Ok ( msg) ) = vite_receiver. next ( ) . await {
93
93
let msg_to_browser = match msg {
94
- Message :: Text ( str) => ws:: Message :: Text ( str) ,
94
+ Message :: Text ( str) => ws:: Message :: Text ( AxumUtf8Bytes :: from ( str. to_string ( ) ) ) ,
95
95
Message :: Ping ( payload) => ws:: Message :: Ping ( payload) ,
96
96
Message :: Pong ( payload) => ws:: Message :: Pong ( payload) ,
97
97
Message :: Binary ( payload) => ws:: Message :: Binary ( payload) ,
@@ -100,7 +100,7 @@ async fn handle_socket(mut tuono_socket: WebSocket) {
100
100
Message :: Close ( _) => ws:: Message :: Close ( None ) ,
101
101
_ => {
102
102
eprintln ! ( "Unexpected message from the vite WebSocket to the browser: {msg:?}" ) ;
103
- ws:: Message :: Text ( "Unhandled" . to_string ( ) )
103
+ ws:: Message :: Text ( "Unhandled" . to_string ( ) . into ( ) )
104
104
}
105
105
} ;
106
106
0 commit comments