From 378c836321e881f712b2963563fd2b5b9b366057 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Fri, 12 Jan 2024 19:27:37 +0000 Subject: [PATCH] chore: add ping command type --- src/ws/mod.rs | 3 +++ src/ws/types.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/ws/mod.rs b/src/ws/mod.rs index 9f77c1a..c9320e0 100644 --- a/src/ws/mod.rs +++ b/src/ws/mod.rs @@ -77,6 +77,7 @@ async fn handle( ) .await?; break (room, id); + } else if let WSCommandType::Ping = out.command_type { } else { return Err(WSCloseType::InvalidState); } @@ -96,6 +97,7 @@ async fn handle( if let Ok(text) = message.to_str() { let out: WSCommand = serde_json::from_str(text)?; match out.command_type { + WSCommandType::Ping => {} WSCommandType::InitializeTransports { init_data } => { let router = room.router().ok_or(WSCloseType::RoomClosed)?; let rtc_state = RtcState::initialize(router, init_data) @@ -151,6 +153,7 @@ async fn event_loop( if let Ok(text) = message.to_str() { let out: WSCommand = serde_json::from_str(text)?; match &out.command_type { + WSCommandType::Ping => {}, WSCommandType::ConnectTransport { connect_data } => { let result = rtc_state.connect_transport(connect_data).await; if let Ok(_) = result { diff --git a/src/ws/types.rs b/src/ws/types.rs index f36bcd0..015a9b9 100644 --- a/src/ws/types.rs +++ b/src/ws/types.rs @@ -19,6 +19,8 @@ pub struct WSCommand { #[derive(Deserialize, IntoStaticStr)] #[serde(tag = "type", content = "data")] pub enum WSCommandType { + Ping, + #[serde(rename_all = "camelCase")] Authenticate { room_id: String,