1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Merge pull request #27193 from bdach/fix-not-working-metadata-hub-cleanup

Fix a few issues in metadata hub's disconnection requested flow
This commit is contained in:
Dean Herbert 2024-02-18 03:46:02 +08:00 committed by GitHub
commit 520576a0fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -13,6 +13,18 @@ namespace osu.Game.Online
/// </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();
}
}

View File

@ -58,6 +58,7 @@ namespace osu.Game.Online.Metadata
// https://github.com/dotnet/aspnetcore/issues/15198
connection.On<BeatmapUpdates>(nameof(IMetadataClient.BeatmapSetsUpdated), ((IMetadataClient)this).BeatmapSetsUpdated);
connection.On<int, UserPresence?>(nameof(IMetadataClient.UserPresenceUpdated), ((IMetadataClient)this).UserPresenceUpdated);
connection.On(nameof(IStatefulUserHubClient.DisconnectRequested), ((IMetadataClient)this).DisconnectRequested);
};
IsConnected.BindTo(connector.IsConnected);
@ -231,7 +232,8 @@ namespace osu.Game.Online.Metadata
public override async Task DisconnectRequested()
{
await base.DisconnectRequested().ConfigureAwait(false);
await EndWatchingUserPresence().ConfigureAwait(false);
if (connector != null)
await connector.Disconnect().ConfigureAwait(false);
}
protected override void Dispose(bool isDisposing)