Skip to content

Commit

Permalink
chore: add ping command type
Browse files Browse the repository at this point in the history
  • Loading branch information
insertish committed Jan 12, 2024
1 parent 488ba0d commit 378c836
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ async fn handle(
)
.await?;
break (room, id);
} else if let WSCommandType::Ping = out.command_type {
} else {
return Err(WSCloseType::InvalidState);
}
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/ws/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 378c836

Please sign in to comment.