Parse ws spec ping messages
This commit is contained in:
@@ -36,6 +36,7 @@ pub enum ServerboundNotification {
|
|||||||
Authenticate(AuthType),
|
Authenticate(AuthType),
|
||||||
BeginTyping { channel: String },
|
BeginTyping { channel: String },
|
||||||
EndTyping { channel: String },
|
EndTyping { channel: String },
|
||||||
|
Ping { data: Vec<u8> }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
@@ -180,6 +181,9 @@ pub enum ClientboundNotification {
|
|||||||
id: String,
|
id: String,
|
||||||
update: Value,
|
update: Value,
|
||||||
},
|
},
|
||||||
|
Pong {
|
||||||
|
data: Vec<u8>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientboundNotification {
|
impl ClientboundNotification {
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ async fn accept(stream: TcpStream) {
|
|||||||
let maybe_decoded = match msg {
|
let maybe_decoded = match msg {
|
||||||
Message::Text(text) => serde_json::from_str::<ServerboundNotification>(&text).map_err(|e| e.to_string()),
|
Message::Text(text) => serde_json::from_str::<ServerboundNotification>(&text).map_err(|e| e.to_string()),
|
||||||
Message::Binary(vec) => rmp_serde::decode::from_read::<&[u8], ServerboundNotification>(vec.as_slice()).map_err(|e| e.to_string()),
|
Message::Binary(vec) => rmp_serde::decode::from_read::<&[u8], ServerboundNotification>(vec.as_slice()).map_err(|e| e.to_string()),
|
||||||
|
Message::Ping(vec) => Ok(ServerboundNotification::Ping { data: vec }),
|
||||||
_ => return Ok(())
|
_ => return Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -296,6 +297,9 @@ async fn accept(stream: TcpStream) {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ServerboundNotification::Ping { data } => {
|
||||||
|
info!("Ping received from User {}. Payload: {:?}", &addr, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user