mirror of
https://github.com/pcvolkmer/arsnova-client.git
synced 2025-04-19 19:16:51 +00:00
fix: keep websocket connection alive by sending empty message as ping
This commit is contained in:
parent
60fe72c8b5
commit
11cb5101a8
@ -28,8 +28,8 @@ use futures_util::{SinkExt, StreamExt};
|
|||||||
use reqwest::{IntoUrl, StatusCode};
|
use reqwest::{IntoUrl, StatusCode};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tokio::join;
|
|
||||||
use tokio::sync::mpsc::{Receiver, Sender};
|
use tokio::sync::mpsc::{Receiver, Sender};
|
||||||
|
use tokio::{join, select};
|
||||||
use tokio_tungstenite::connect_async;
|
use tokio_tungstenite::connect_async;
|
||||||
use tokio_tungstenite::tungstenite::Message;
|
use tokio_tungstenite::tungstenite::Message;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@ -212,6 +212,7 @@ pub enum FeedbackHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A possible feedback value
|
/// A possible feedback value
|
||||||
|
#[derive(Clone)]
|
||||||
pub enum FeedbackValue {
|
pub enum FeedbackValue {
|
||||||
VeryGood,
|
VeryGood,
|
||||||
A,
|
A,
|
||||||
@ -456,11 +457,16 @@ impl Client<LoggedIn> {
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => loop {
|
Ok(_) => loop {
|
||||||
if let Some(value) = receiver.recv().await {
|
select!(
|
||||||
let msg = WsCreateFeedbackMessage::new(&room_info.id, &user_id, value)
|
Some(value) = receiver.recv() =>
|
||||||
.to_string();
|
{
|
||||||
|
let msg = WsCreateFeedbackMessage::new(&room_info.id, &user_id, value.to_owned()).to_string();
|
||||||
let _ = write.send(Message::Text(msg)).await;
|
let _ = write.send(Message::Text(msg)).await;
|
||||||
};
|
},
|
||||||
|
_ = tokio::time::sleep(Duration::from_secs(15)) => {
|
||||||
|
let _ = write.send(Message::Text("\n".to_string())).await;
|
||||||
|
}
|
||||||
|
)
|
||||||
},
|
},
|
||||||
Err(_) => Err(ConnectionError),
|
Err(_) => Err(ConnectionError),
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user