Expose event from OnlineMetadataClient rather than calling BeatmapUpdater directly

This commit is contained in:
Dean Herbert
2022-07-14 15:18:12 +09:00
parent 6ea380d649
commit cd39f444ef
3 changed files with 12 additions and 16 deletions

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -11,5 +13,13 @@ namespace osu.Game.Online.Metadata
public abstract Task BeatmapSetsUpdated(BeatmapUpdates updates); public abstract Task BeatmapSetsUpdated(BeatmapUpdates updates);
public abstract Task<BeatmapUpdates> GetChangesSince(int queueId); public abstract Task<BeatmapUpdates> GetChangesSince(int queueId);
public Action<int[]>? ChangedBeatmapSetsArrived;
protected Task ProcessChanges(int[] beatmapSetIDs)
{
ChangedBeatmapSetsArrived?.Invoke(beatmapSetIDs.Distinct().ToArray());
return Task.CompletedTask;
}
} }
} }

View File

@ -7,7 +7,6 @@ using Microsoft.AspNetCore.SignalR.Client;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Online.API; using osu.Game.Online.API;
@ -15,7 +14,6 @@ namespace osu.Game.Online.Metadata
{ {
public class OnlineMetadataClient : MetadataClient public class OnlineMetadataClient : MetadataClient
{ {
private readonly BeatmapUpdater beatmapUpdater;
private readonly string endpoint; private readonly string endpoint;
private IHubClientConnector? connector; private IHubClientConnector? connector;
@ -24,9 +22,8 @@ namespace osu.Game.Online.Metadata
private HubConnection? connection => connector?.CurrentConnection; private HubConnection? connection => connector?.CurrentConnection;
public OnlineMetadataClient(EndpointConfiguration endpoints, BeatmapUpdater beatmapUpdater) public OnlineMetadataClient(EndpointConfiguration endpoints)
{ {
this.beatmapUpdater = beatmapUpdater;
endpoint = endpoints.MetadataEndpointUrl; endpoint = endpoints.MetadataEndpointUrl;
} }
@ -102,17 +99,6 @@ namespace osu.Game.Online.Metadata
await ProcessChanges(updates.BeatmapSetIDs); await ProcessChanges(updates.BeatmapSetIDs);
} }
protected Task ProcessChanges(int[] beatmapSetIDs)
{
foreach (int id in beatmapSetIDs)
{
Logger.Log($"Processing {id}...");
beatmapUpdater.Queue(id);
}
return Task.CompletedTask;
}
public override Task<BeatmapUpdates> GetChangesSince(int queueId) public override Task<BeatmapUpdates> GetChangesSince(int queueId)
{ {
if (connector?.IsConnected.Value != true) if (connector?.IsConnected.Value != true)

View File

@ -287,7 +287,7 @@ namespace osu.Game
dependencies.CacheAs(spectatorClient = new OnlineSpectatorClient(endpoints)); dependencies.CacheAs(spectatorClient = new OnlineSpectatorClient(endpoints));
dependencies.CacheAs(multiplayerClient = new OnlineMultiplayerClient(endpoints)); dependencies.CacheAs(multiplayerClient = new OnlineMultiplayerClient(endpoints));
dependencies.CacheAs(metadataClient = new OnlineMetadataClient(endpoints, beatmapUpdater)); dependencies.CacheAs(metadataClient = new OnlineMetadataClient(endpoints));
BeatmapManager.ProcessBeatmap = set => beatmapUpdater.Process(set); BeatmapManager.ProcessBeatmap = set => beatmapUpdater.Process(set);