Removes not needed server messages in & out

This commit is contained in:
Franklin 2023-02-28 19:21:38 -04:00
parent f6ea7041a7
commit ba88d60cf6
2 changed files with 0 additions and 23 deletions

View File

@ -30,9 +30,6 @@ pub enum ServerMessageIn {
/// Client can send this to server to fetch old messages.
/// By Old messages I mean: Messages that have already been delivered/seen
FetchMessages(),
JoinGroup(),
LeaveGroup(),
}
impl Display for ServerMessageIn {
@ -42,8 +39,6 @@ impl Display for ServerMessageIn {
ServerMessageIn::Logout => write!(f, "LOGOUT"),
ServerMessageIn::SeeMessages(_) => write!(f, "SEE MESSAGES"),
ServerMessageIn::SendMessage(_) => write!(f, "SEND MESSAGE"),
ServerMessageIn::JoinGroup() => write!(f, "JOIN GROUP"),
ServerMessageIn::LeaveGroup() => write!(f, "LEAVE GROUP"),
ServerMessageIn::FetchMessages() => write!(f, "FETCH MESSAGES"),
}
}
@ -58,8 +53,6 @@ impl Receivable for ServerMessageIn {
"LOGOUT" => Ok(Self::Logout),
"SEE MESSAGES" => Ok(Self::SeeMessages(serde_json::from_value(message.body)?)),
"SEND MESSAGE" => Ok(Self::SendMessage(serde_json::from_value(message.body)?)),
"JOIN GROUP" => Ok(Self::JoinGroup()),
"LEAVE GROUP" => Ok(Self::LeaveGroup()),
"FETCH MESSAGES" => Ok(Self::FetchMessages()),
_ => Err(SocketError::boxed_error(format!(
"ClientMessage recieved isn't recognized by the server. ClientMessage: {:#?}",
@ -93,14 +86,6 @@ impl Sendable for ServerMessageIn {
head,
body: serde_json::Value::Null,
}),
ServerMessageIn::JoinGroup() => Ok(ClientMessage {
head,
body: serde_json::Value::Null,
}),
ServerMessageIn::LeaveGroup() => Ok(ClientMessage {
head,
body: serde_json::Value::Null,
}),
}
}
}

View File

@ -17,9 +17,7 @@ pub trait Sendable {
/// Message sent from Server to client
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum ServerMessageOut {
Acknowledge,
LoggedIn,
/// Whenever a user sends a message
MessageSent,
/// Whenever a user gets a message
@ -43,7 +41,6 @@ pub struct MessageTimeChangeUpdate {
impl Display for ServerMessageOut {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ServerMessageOut::Acknowledge => write!(f, "ACKNOWLEDGE"),
ServerMessageOut::LoggedIn => write!(f, "LOGGED IN"),
ServerMessageOut::MessageSent => write!(f, "MESSAGE SENT"),
ServerMessageOut::MessageRecieved(_) => write!(f, "MESSAGE RECIEVED"),
@ -58,10 +55,6 @@ impl Sendable for ServerMessageOut {
fn into_message(self) -> Result<ClientMessage, Box<(dyn std::error::Error + Send + Sync)>> {
let head = self.to_string();
match self {
ServerMessageOut::Acknowledge => Ok(ClientMessage {
head,
body: Value::Null,
}),
ServerMessageOut::LoggedIn => Ok(ClientMessage {
head,
body: Value::Null,
@ -99,7 +92,6 @@ impl Receivable for ServerMessageOut {
{
let head = message.head.as_str();
match head {
"ACKNOWLEDGE" => Ok(ServerMessageOut::Acknowledge),
"MESSAGE SENT" => Ok(ServerMessageOut::MessageSent),
"MESSAGE RECIEVED" => Ok(ServerMessageOut::MessageRecieved(serde_json::from_value(
message.body,