1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 08:07:26 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Multiplayer/Multiplayer.cs
Dean Herbert 45c578b857 Remove selection polling from multiplayer
Looks like this was just copy-paste without any thought into whether it
should exist. It really shouldn't exist.

This is a thing for the playlists system because the *whole system*
there relies on polling the web API to get updated information. In the
case of mutliplayer, we hand off all communications to the realtime
server at the point of joining the rooms.

The argument that this was there to do faster polling on the selection
isn't valid since the polling times were the same for both cases.

Closes #11348.
2020-12-29 15:10:09 +09:00

71 lines
2.4 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Extensions;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Lounge;
namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
public class Multiplayer : OnlinePlayScreen
{
[Resolved]
private StatefulMultiplayerClient client { get; set; }
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
if (client.Room != null)
client.ChangeState(MultiplayerUserState.Idle).CatchUnobservedExceptions(true);
}
protected override void UpdatePollingRate(bool isIdle)
{
var multiplayerRoomManager = (MultiplayerRoomManager)RoomManager;
if (!this.IsCurrentScreen())
{
multiplayerRoomManager.TimeBetweenListingPolls.Value = 0;
}
else
{
switch (CurrentSubScreen)
{
case LoungeSubScreen _:
multiplayerRoomManager.TimeBetweenListingPolls.Value = isIdle ? 120000 : 15000;
break;
// Don't poll inside the match or anywhere else.
default:
multiplayerRoomManager.TimeBetweenListingPolls.Value = 0;
break;
}
}
Logger.Log($"Polling adjusted (listing: {multiplayerRoomManager.TimeBetweenListingPolls.Value})");
}
protected override Room CreateNewRoom()
{
var room = new Room { Name = { Value = $"{API.LocalUser}'s awesome room" } };
room.Category.Value = RoomCategory.Realtime;
return room;
}
protected override string ScreenTitle => "Multiplayer";
protected override RoomManager CreateRoomManager() => new MultiplayerRoomManager();
protected override LoungeSubScreen CreateLounge() => new MultiplayerLoungeSubScreen();
protected override OsuButton CreateNewMultiplayerGameButton() => new CreateMultiplayerMatchButton();
}
}