implemented Ping Message response and some fixes
This commit is contained in:
@@ -241,7 +241,7 @@ pub async fn run_server(args: Vec<String>) {
|
|||||||
// the update handling task
|
// the update handling task
|
||||||
let update_mutexes = mutexes.clone();
|
let update_mutexes = mutexes.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
proto::update_thread(update_rx, update_mutexes);
|
proto::update_thread(update_rx, update_mutexes).await.handle().extra_msg("update thread crashed").is_critical();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -372,6 +372,9 @@ async fn handle_websocket_connection(
|
|||||||
proto::MizeMessage::Bin(bin_msg) => {
|
proto::MizeMessage::Bin(bin_msg) => {
|
||||||
socket_tx.send(Message::Binary(bin_msg.raw)).await;
|
socket_tx.send(Message::Binary(bin_msg.raw)).await;
|
||||||
}
|
}
|
||||||
|
proto::MizeMessage::Pong() => {
|
||||||
|
socket_tx.send(Message::Pong(Vec::new())).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -475,11 +478,7 @@ async fn handle_websocket_connection(
|
|||||||
|
|
||||||
|
|
||||||
Message::Ping(_) => {
|
Message::Ping(_) => {
|
||||||
let err = MizeError::new(11)
|
msg_tx.send(MizeMessage::Pong());
|
||||||
.extra_msg("unhandeld WebSocket-Message type: Ping")
|
|
||||||
.handle();
|
|
||||||
|
|
||||||
msg_tx.send(proto::MizeMessage::Json(err.to_json_message())).await;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ use serde::{Serialize, Deserialize};
|
|||||||
pub enum MizeMessage {
|
pub enum MizeMessage {
|
||||||
Json(JsonMessage),
|
Json(JsonMessage),
|
||||||
Bin(BinMessage),
|
Bin(BinMessage),
|
||||||
|
Pong(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -160,7 +161,6 @@ pub struct UpdateMessage {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct Delta {
|
pub struct Delta {
|
||||||
#[serde(flatten)]
|
|
||||||
pub delta: Vec<(Path, JsonValue)>,
|
pub delta: Vec<(Path, JsonValue)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,12 +386,14 @@ pub async fn handle_json_msg(msg: JsonMessage, origin: Peer, mutexes: Mutexes) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_update(update: Update, origin: Peer, mutexes: Mutexes) -> Result<(), MizeError> {
|
pub async fn handle_update(update: Update, origin: Peer, mutexes: Mutexes) -> Result<(), MizeError> {
|
||||||
mutexes.update_tx.send((update, origin));
|
mutexes.update_tx.send((update, origin)).await.map_err(|err| MizeError::new(11).extra_msg(format!("From SendError: {}", err)));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_thread(mut update_rx: mpsc::Receiver<(Update, Peer)>, mutexes: Mutexes) -> Result<(), MizeError> {
|
pub async fn update_thread(mut update_rx: mpsc::Receiver<(Update, Peer)>, mutexes: Mutexes) -> Result<(), MizeError> {
|
||||||
while let Some((update, origin)) = update_rx.recv().await {
|
while let Some((update, origin)) = update_rx.recv().await {
|
||||||
|
println!("UPDATE: {:?}", update.iter().next().unwrap().0);
|
||||||
|
println!("DELTA: {:?}", update.iter().next().unwrap().1);
|
||||||
//TODO: run update code from modules and types
|
//TODO: run update code from modules and types
|
||||||
|
|
||||||
let itemstore = mutexes.itemstore.lock().await;
|
let itemstore = mutexes.itemstore.lock().await;
|
||||||
|
|||||||
Reference in New Issue
Block a user