Update Websocket to fix premature closing w 1006
This commit is contained in:
parent
6fdff97722
commit
172c000813
|
@ -341,18 +341,25 @@ impl<'a> WebSocketConnection {
|
|||
|
||||
let (mut ws_tx, mut ws_rx) = ws_stream.split();
|
||||
|
||||
// Send messages from the send channel
|
||||
while let Some(msg) = send_channel_read.recv().await {
|
||||
ws_tx.send(msg).await.unwrap();
|
||||
}
|
||||
loop {
|
||||
|
||||
// Write received messages to the receive channel
|
||||
while let Some(msg) = ws_rx.next().await {
|
||||
let msg = ws_rx.next().await;
|
||||
if msg.as_ref().is_some() {
|
||||
let msg_unwrapped = msg.unwrap().unwrap();
|
||||
receive_channel_write
|
||||
.send(msg.unwrap())
|
||||
.send(msg_unwrapped)
|
||||
.await
|
||||
.unwrap();
|
||||
};
|
||||
|
||||
// Send messages from the send channel
|
||||
let msg = send_channel_read.recv().await;
|
||||
if msg.as_ref().is_some() {
|
||||
let msg_unwrapped = msg.unwrap();
|
||||
ws_tx.send(msg_unwrapped).await.unwrap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
WebSocketConnection {
|
||||
|
|
Loading…
Reference in New Issue