Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few issues in metadata hub's disconnection requested flow #27193

Merged
merged 4 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions osu.Game/Online/IStatefulUserHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
4 changes: 3 additions & 1 deletion osu.Game/Online/Metadata/OnlineMetadataClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private void load(IAPIProvider api, OsuConfigManager config)
// 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);
Expand Down Expand Up @@ -231,7 +232,8 @@ public override async Task EndWatchingUserPresence()
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)
Expand Down
Loading