1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 20:07:29 +08:00

Remove unnecessary first-frame polling + address concerns

This commit is contained in:
smoogipoo 2020-12-20 18:05:43 +09:00
parent 812a1d2b4f
commit fb61cdfd41
2 changed files with 18 additions and 10 deletions

View File

@ -27,7 +27,8 @@ namespace osu.Game.Screens.Multi.Components
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]
private RulesetStore rulesets { get; set; }
@ -64,7 +65,7 @@ namespace osu.Game.Screens.Multi.Components
req.Success += result =>
{
JoinedRoom = room;
joinedRoom.Value = room;
update(room, result);
addRoom(room);
@ -93,7 +94,7 @@ namespace osu.Game.Screens.Multi.Components
currentJoinRoomRequest.Success += () =>
{
JoinedRoom = room;
joinedRoom.Value = room;
onSuccess?.Invoke(room);
};
@ -114,8 +115,8 @@ namespace osu.Game.Screens.Multi.Components
if (JoinedRoom == null)
return;
api.Queue(new PartRoomRequest(JoinedRoom));
JoinedRoom = null;
api.Queue(new PartRoomRequest(joinedRoom.Value));
joinedRoom.Value = null;
}
private readonly HashSet<int> ignoredRooms = new HashSet<int>();

View File

@ -30,7 +30,8 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
base.LoadComplete();
isConnected.BindTo(multiplayerClient.IsConnected);
isConnected.BindValueChanged(_ => Schedule(updatePolling), true);
isConnected.BindValueChanged(_ => Schedule(updatePolling));
JoinedRoom.BindValueChanged(_ => updatePolling());
updatePolling();
}
@ -46,7 +47,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
if (JoinedRoom == null)
return;
var joinedRoom = JoinedRoom;
var joinedRoom = JoinedRoom.Value;
base.PartRoom();
multiplayerClient.LeaveRoom().Wait();
@ -77,7 +78,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
ClearRooms();
// 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[]
@ -102,8 +103,11 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
{
base.LoadComplete();
AllowPolling.BindValueChanged(_ =>
AllowPolling.BindValueChanged(allowPolling =>
{
if (!allowPolling.NewValue)
return;
if (IsLoaded)
PollImmediately();
});
@ -120,8 +124,11 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
{
base.LoadComplete();
AllowPolling.BindValueChanged(_ =>
AllowPolling.BindValueChanged(allowPolling =>
{
if (!allowPolling.NewValue)
return;
if (IsLoaded)
PollImmediately();
});