summaryrefslogtreecommitdiff
path: root/gateway/src/connection/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'gateway/src/connection/utils.rs')
-rw-r--r--gateway/src/connection/utils.rs42
1 files changed, 0 insertions, 42 deletions
diff --git a/gateway/src/connection/utils.rs b/gateway/src/connection/utils.rs
deleted file mode 100644
index bb425da..0000000
--- a/gateway/src/connection/utils.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-use std::str::from_utf8;
-use tokio_tungstenite::tungstenite::Message;
-use common::log::info;
-
-use crate::error::GatewayError;
-
-use super::Connection;
-
-impl Connection {
-
- /// Handles the websocket events and calls the _handle_discord_message function for the deserialization.
- pub(super) async fn _handle_message(
- &mut self,
- data: &Message,
- ) -> Result<crate::payloads::gateway::Message, GatewayError> {
- match data {
- Message::Text(text) => self._handle_discord_message(&text).await,
- Message::Binary(message) => {
- match from_utf8(message) {
- Ok(data) => self._handle_discord_message(data).await,
- Err(err) => Err(GatewayError::from(err.to_string())),
- }
- },
- Message::Close(close_frame) => {
- info!("Discord connection closed {:?}", close_frame);
- Err(GatewayError::from("connection closed".to_string()))
- },
- _ => Err(GatewayError::from(format!("unknown variant of message specified to the handler {}", data).to_string())),
- }
- }
-
- /// Handle the decompression and deserialization process of a discord payload.
- pub(super) async fn _handle_discord_message(
- &mut self,
- raw_message: &str,
- ) -> Result<crate::payloads::gateway::Message, GatewayError> {
- match serde_json::from_str(raw_message) {
- Ok(message) => Ok(message),
- Err(err) => Err(GatewayError::from(err.to_string())),
- }
- }
-}