mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 23:02:54 +08:00
Remove unnecessary first-frame polling + address concerns
This commit is contained in:
parent
812a1d2b4f
commit
fb61cdfd41
@ -27,7 +27,8 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
|
|
||||||
public IBindableList<Room> Rooms => rooms;
|
public IBindableList<Room> Rooms => rooms;
|
||||||
|
|
||||||
protected Room JoinedRoom { get; private set; }
|
protected IBindable<Room> JoinedRoom => joinedRoom;
|
||||||
|
private readonly Bindable<Room> joinedRoom = new Bindable<Room>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesets { get; set; }
|
private RulesetStore rulesets { get; set; }
|
||||||
@ -64,7 +65,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
|
|
||||||
req.Success += result =>
|
req.Success += result =>
|
||||||
{
|
{
|
||||||
JoinedRoom = room;
|
joinedRoom.Value = room;
|
||||||
|
|
||||||
update(room, result);
|
update(room, result);
|
||||||
addRoom(room);
|
addRoom(room);
|
||||||
@ -93,7 +94,7 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
|
|
||||||
currentJoinRoomRequest.Success += () =>
|
currentJoinRoomRequest.Success += () =>
|
||||||
{
|
{
|
||||||
JoinedRoom = room;
|
joinedRoom.Value = room;
|
||||||
onSuccess?.Invoke(room);
|
onSuccess?.Invoke(room);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,8 +115,8 @@ namespace osu.Game.Screens.Multi.Components
|
|||||||
if (JoinedRoom == null)
|
if (JoinedRoom == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
api.Queue(new PartRoomRequest(JoinedRoom));
|
api.Queue(new PartRoomRequest(joinedRoom.Value));
|
||||||
JoinedRoom = null;
|
joinedRoom.Value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly HashSet<int> ignoredRooms = new HashSet<int>();
|
private readonly HashSet<int> ignoredRooms = new HashSet<int>();
|
||||||
|
@ -30,7 +30,8 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
isConnected.BindTo(multiplayerClient.IsConnected);
|
isConnected.BindTo(multiplayerClient.IsConnected);
|
||||||
isConnected.BindValueChanged(_ => Schedule(updatePolling), true);
|
isConnected.BindValueChanged(_ => Schedule(updatePolling));
|
||||||
|
JoinedRoom.BindValueChanged(_ => updatePolling());
|
||||||
|
|
||||||
updatePolling();
|
updatePolling();
|
||||||
}
|
}
|
||||||
@ -46,7 +47,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
if (JoinedRoom == null)
|
if (JoinedRoom == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var joinedRoom = JoinedRoom;
|
var joinedRoom = JoinedRoom.Value;
|
||||||
|
|
||||||
base.PartRoom();
|
base.PartRoom();
|
||||||
multiplayerClient.LeaveRoom().Wait();
|
multiplayerClient.LeaveRoom().Wait();
|
||||||
@ -77,7 +78,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
ClearRooms();
|
ClearRooms();
|
||||||
|
|
||||||
// Don't poll when not connected or when a room has been joined.
|
// Don't poll when not connected or when a room has been joined.
|
||||||
allowPolling.Value = isConnected.Value && JoinedRoom == null;
|
allowPolling.Value = isConnected.Value && JoinedRoom.Value == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override RoomPollingComponent[] CreatePollingComponents() => new RoomPollingComponent[]
|
protected override RoomPollingComponent[] CreatePollingComponents() => new RoomPollingComponent[]
|
||||||
@ -102,8 +103,11 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
AllowPolling.BindValueChanged(_ =>
|
AllowPolling.BindValueChanged(allowPolling =>
|
||||||
{
|
{
|
||||||
|
if (!allowPolling.NewValue)
|
||||||
|
return;
|
||||||
|
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
PollImmediately();
|
PollImmediately();
|
||||||
});
|
});
|
||||||
@ -120,8 +124,11 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
AllowPolling.BindValueChanged(_ =>
|
AllowPolling.BindValueChanged(allowPolling =>
|
||||||
{
|
{
|
||||||
|
if (!allowPolling.NewValue)
|
||||||
|
return;
|
||||||
|
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
PollImmediately();
|
PollImmediately();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user