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