1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-19 02:29:53 +08:00
Files
osu-lazer/osu.Game/Online/IStatefulUserHubClient.cs
T
Dean Herbert 51b4e89773 Eagerly connect to latest server instance for best online experience (#37506)
Client side requirements for making the client connect as soon as
possible, based on how the client is being used. This is especially
important with the introduction of ranked play: previously the worst
case scenario would be that you couldn't join a multiplayer room (or
spectate a user) and this was [automatically
handled](https://github.com/ppy/osu/blob/f66e2c432fdb08db46477c4fa08ca74e551d037f/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs#L115-L121)
mostly*, but now, if you leave the game open for a while, you can
potentially be stuck queueing in ranked play with no users remaining on
your server.

Some samples of how this looks follow. Do note that the client is
showing "Server is shutting down" errors. This is only going to happen
in local debug environments – In production, when you reconnect to the
endpoint you will always get a non-shutting-down instance.

Idle scenario:


https://github.com/user-attachments/assets/dd47fdf6-8d49-48e3-a19f-b196a581070b

Non-idle scenario:


https://github.com/user-attachments/assets/dfc8a41a-83fb-4b08-94b4-9595faf88294

* Spectator isn't handled properly, as one example.
2026-05-05 16:06:00 +09:00

44 lines
1.8 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 System.Threading.Tasks;
namespace osu.Game.Online
{
/// <summary>
/// Common interface for clients of "stateful user hubs", i.e. server-side hubs
/// that preserve user state.
/// In the case of such hubs, concurrency constraints are enforced (only one client
/// can be connected at a time).
/// </summary>
public interface IStatefulUserHubClient
{
/// <summary>
/// Invoked when the server requests a client to disconnect.
/// </summary>
/// <remarks>
/// When this request is received, the client must presume any and all further requests to the server
/// will either fail or be ignored.
/// This method is ONLY to be used for the purposes of:
/// <list type="bullet">
/// <item>actually physically disconnecting from the server,</item>
/// <item>cleaning up / setting up any and all required local client state.</item>
/// </list>
/// </remarks>
Task DisconnectRequested();
/// <summary>
/// Invoked when server begins a shutdown sequence.
/// </summary>
/// <remarks>
/// Server shutdowns are graceful.
///
/// This will fire with hours of notice for clients to do what they need to and subsequently
/// disconnect. It's in the client's best interest to switch over to the new hubs as soon as
/// it can, so that the user can be on the same server as the majority of others (and avoid a
/// "server split" scenario where users are split across multiple shutting-down hubs).
/// </remarks>
Task ServerShuttingDown();
}
}