Handle both numerical and binary pings.
This commit is contained in:
@@ -22,13 +22,20 @@ pub struct Auth {
|
|||||||
pub token: String,
|
pub token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum Ping {
|
||||||
|
Binary(Vec<u8>),
|
||||||
|
Number(usize)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum ServerboundNotification {
|
pub enum ServerboundNotification {
|
||||||
Authenticate(Auth),
|
Authenticate(Auth),
|
||||||
BeginTyping { channel: String },
|
BeginTyping { channel: String },
|
||||||
EndTyping { channel: String },
|
EndTyping { channel: String },
|
||||||
Ping { data: Vec<u8>, responded: Option<()> },
|
Ping { data: Ping, responded: Option<()> },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
@@ -79,7 +86,7 @@ pub enum ClientboundNotification {
|
|||||||
channels: Vec<Channel>,
|
channels: Vec<Channel>,
|
||||||
members: Vec<Member>,
|
members: Vec<Member>,
|
||||||
},
|
},
|
||||||
Pong { data: Vec<u8> },
|
Pong { data: Ping },
|
||||||
|
|
||||||
Message(Message),
|
Message(Message),
|
||||||
MessageUpdate {
|
MessageUpdate {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::database::*;
|
use crate::database::*;
|
||||||
|
use crate::notifications::events::Ping;
|
||||||
use crate::util::variables::WS_HOST;
|
use crate::util::variables::WS_HOST;
|
||||||
|
|
||||||
use super::subscriptions;
|
use super::subscriptions;
|
||||||
@@ -140,7 +141,7 @@ async fn accept(stream: TcpStream) {
|
|||||||
rmp_serde::decode::from_read::<&[u8], ServerboundNotification>(vec.as_slice())
|
rmp_serde::decode::from_read::<&[u8], ServerboundNotification>(vec.as_slice())
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
Message::Ping(vec) => Ok(ServerboundNotification::Ping { data: vec, responded: Some(()) }),
|
Message::Ping(vec) => Ok(ServerboundNotification::Ping { data: Ping::Binary(vec), responded: Some(()) }),
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user