forked from lavina/lavina
1
0
Fork 0
This commit is contained in:
Nikita Vilunov 2024-05-10 15:22:51 +02:00
parent cb889193c7
commit 3e414f4038
3 changed files with 14 additions and 10 deletions

View File

@ -26,6 +26,7 @@ impl Broadcasting {
} }
/// Broadcasts the given update to subscribed player actors on local node. /// 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( pub async fn broadcast(
&self, &self,
players: &PlayerRegistry, players: &PlayerRegistry,

View File

@ -721,16 +721,18 @@ impl Player {
async fn get_rooms(&self) -> Vec<RoomInfo> { async fn get_rooms(&self) -> Vec<RoomInfo> {
let mut response = vec![]; let mut response = vec![];
for (room_id, handle) in &self.my_rooms { for (room_id, handle) in &self.my_rooms {
if let RoomRef::Local(handle) = handle { match handle {
response.push(handle.get_room_info().await); RoomRef::Local(handle) => {
} else { response.push(handle.get_room_info().await);
let room_info = RoomInfo { }
id: room_id.clone(), RoomRef::Remote { .. } => {
topic: "unknown".into(), let room_info = RoomInfo {
members: vec![], id: room_id.clone(),
}; topic: "unknown".into(),
response.push(room_info); members: vec![],
// TODO };
response.push(room_info);
}
} }
} }
response response

View File

@ -50,6 +50,7 @@ impl Storage {
} }
pub async fn create_or_retrieve_room_id_by_name(&self, name: &str) -> Result<u32> { pub async fn create_or_retrieve_room_id_by_name(&self, name: &str) -> Result<u32> {
// 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 mut executor = self.conn.lock().await;
let res: (u32,) = sqlx::query_as( let res: (u32,) = sqlx::query_as(
"insert into rooms(name, topic) "insert into rooms(name, topic)