From 84bdcab0d14040dce72cb5dda09c263c6087b1b6 Mon Sep 17 00:00:00 2001 From: Alex Emmet <111742636+Alex-Emmet@users.noreply.github.com> Date: Sun, 15 Feb 2026 12:15:37 +0100 Subject: [PATCH] [WIP] Client connections --- src/main.rs | 8 ++++---- src/omega/omega_connection.rs | 2 +- src/rho/client_connection.rs | 2 +- src/rho/iota_connection.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index f6731f9..1e92720 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,7 +60,7 @@ async fn main() { let mut path: String = "/".to_string(); let callback = |req: &Request, response: Response| { - path = req.uri().path().to_string(); // Extract URI path + path = req.uri().path().to_string(); Ok(response) }; let ws_stream = match accept_hdr_async(stream.compat(), callback).await { @@ -71,7 +71,7 @@ async fn main() { } }; let (sender, receiver) = ws_stream.split(); - if path == "/ws/client/" { + if path.starts_with("/ws/client") { log_in!(0, PrintType::Client, "New Client connection"); let client_conn: Arc = Arc::from(ClientConnection::new(sender, receiver)); @@ -117,7 +117,7 @@ async fn main() { } } } - } else if path == "/ws/anonymous_client/" { + } else if path.starts_with("/ws/anonymous_client") { log_in!(0, PrintType::Client, "New Anonymous Client connection"); let client_conn: Arc = Arc::from(AnonymousClientConnection::new(sender, receiver)); @@ -176,7 +176,7 @@ async fn main() { } } } - } else if path == "/ws/iota/" { + } else if path.starts_with("/ws/iota") { log_in!(0, PrintType::Iota, "New Iota connection"); let iota_conn: Arc = Arc::from(IotaConnection::new(sender, receiver)); diff --git a/src/omega/omega_connection.rs b/src/omega/omega_connection.rs index e42d5ed..2a8c8e0 100755 --- a/src/omega/omega_connection.rs +++ b/src/omega/omega_connection.rs @@ -349,7 +349,7 @@ impl OmegaConnection { match msg { Some(Ok(Message::Text(msg))) => { let cv = CommunicationValue::from_json(&msg); - if cv.is_type(CommunicationType::pong) { + if cv.is_type(CommunicationType::pong) || cv.is_type(CommunicationType::ping) { self.handle_pong(&cv, true).await; continue; } diff --git a/src/rho/client_connection.rs b/src/rho/client_connection.rs index 9e54f1f..486fb6b 100644 --- a/src/rho/client_connection.rs +++ b/src/rho/client_connection.rs @@ -109,7 +109,7 @@ impl ClientConnection { ); return; } - if !cv.is_type(CommunicationType::pong) { + if !cv.is_type(CommunicationType::pong) && !cv.is_type(CommunicationType::ping) { log_out!( self.get_user_id().await, PrintType::Client, diff --git a/src/rho/iota_connection.rs b/src/rho/iota_connection.rs index 72ed224..69d95d2 100755 --- a/src/rho/iota_connection.rs +++ b/src/rho/iota_connection.rs @@ -149,7 +149,7 @@ impl IotaConnection { pub async fn handle_message(self: Arc, message: Utf8Bytes) { let cv = CommunicationValue::from_json(&message); // Handle ping - if cv.is_type(CommunicationType::ping) { + if cv.is_type(CommunicationType::ping) || cv.is_type(CommunicationType::pong) { self.handle_ping(cv).await; return; }