From 3e414f4038e0077c79c89c9863035ced0cf93fc0 Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Fri, 10 May 2024 15:22:51 +0200 Subject: [PATCH] wip --- .../lavina-core/src/clustering/broadcast.rs | 1 + crates/lavina-core/src/player.rs | 22 ++++++++++--------- crates/lavina-core/src/repo/room.rs | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/lavina-core/src/clustering/broadcast.rs b/crates/lavina-core/src/clustering/broadcast.rs index f42754a..8e9301b 100644 --- a/crates/lavina-core/src/clustering/broadcast.rs +++ b/crates/lavina-core/src/clustering/broadcast.rs @@ -26,6 +26,7 @@ impl Broadcasting { } /// Broadcasts the given update to subscribed player actors on local node. + #[tracing::instrument(skip(self, players, message, created_at), name = "Broadcasting::broadcast")] pub async fn broadcast( &self, players: &PlayerRegistry, diff --git a/crates/lavina-core/src/player.rs b/crates/lavina-core/src/player.rs index 9387991..fea1fc9 100644 --- a/crates/lavina-core/src/player.rs +++ b/crates/lavina-core/src/player.rs @@ -721,16 +721,18 @@ impl Player { async fn get_rooms(&self) -> Vec { let mut response = vec![]; for (room_id, handle) in &self.my_rooms { - if let RoomRef::Local(handle) = handle { - response.push(handle.get_room_info().await); - } else { - let room_info = RoomInfo { - id: room_id.clone(), - topic: "unknown".into(), - members: vec![], - }; - response.push(room_info); - // TODO + match handle { + RoomRef::Local(handle) => { + response.push(handle.get_room_info().await); + } + RoomRef::Remote { .. } => { + let room_info = RoomInfo { + id: room_id.clone(), + topic: "unknown".into(), + members: vec![], + }; + response.push(room_info); + } } } response diff --git a/crates/lavina-core/src/repo/room.rs b/crates/lavina-core/src/repo/room.rs index d831b74..2d695d6 100644 --- a/crates/lavina-core/src/repo/room.rs +++ b/crates/lavina-core/src/repo/room.rs @@ -50,6 +50,7 @@ impl Storage { } pub async fn create_or_retrieve_room_id_by_name(&self, name: &str) -> Result { + // TODO we don't need any info except the name on non-owning nodes, should remove stubs here let mut executor = self.conn.lock().await; let res: (u32,) = sqlx::query_as( "insert into rooms(name, topic)