Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion phira-mp-server/src/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ impl Room {
.to_client(self.chart.read().await.as_ref().map(|it| it.id))
}

pub async fn fake_room_state(&self) -> RoomState {
RoomState::SelectChart(self.chart.read().await.as_ref().map(|it| it.id))
}

pub async fn client_state(&self, user: &User) -> ClientRoomState {
ClientRoomState {
id: self.id.clone(),
state: self.client_room_state().await,
state: self.fake_room_state().await,
live: self.is_live(),
locked: self.is_locked(),
cycle: self.is_cycle(),
Expand Down
14 changes: 13 additions & 1 deletion phira-mp-server/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use anyhow::{anyhow, bail, Result};
use phira_mp_common::{
ClientCommand, JoinRoomResponse, Message, ServerCommand, Stream, UserInfo,
HEARTBEAT_DISCONNECT_TIMEOUT,
RoomState, HEARTBEAT_DISCONNECT_TIMEOUT,
};
use serde::Deserialize;
use std::{
Expand Down Expand Up @@ -253,6 +253,18 @@ impl Session {
room_state,
))))
.await;

if let Some(room) = user.room.read().await.as_ref() {
let state = room.client_room_state().await;

if !matches!(state, RoomState::SelectChart(_)) {

time::sleep(Duration::from_nanos(1)).await;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

Copy link
Copy Markdown
Author

@lRENyaaa lRENyaaa Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们需要立即切换状态,但是若不使用 time::sleep ,会在客户端导致panic,说实话我并不明白什么原因导致了这个问题,但是不得不这么做


let _ = send_tx.send(ServerCommand::ChangeState(state)).await;
}
};

waiting_for_authenticate.store(false, Ordering::SeqCst);
}
return;
Expand Down