Make APIAccess a component

This commit is contained in:
Dean Herbert
2018-03-14 10:42:58 +09:00
parent 83cd2fd317
commit 07642546bb
5 changed files with 14 additions and 41 deletions

View File

@ -8,15 +8,15 @@ using System.Diagnostics;
using System.Net;
using System.Threading;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Framework.Threading;
using osu.Game.Configuration;
using osu.Game.Online.API.Requests;
using osu.Game.Users;
namespace osu.Game.Online.API
{
public class APIAccess : IAPIProvider, IDisposable
public class APIAccess : Component, IAPIProvider
{
private readonly OsuConfigManager config;
private readonly OAuth authentication;
@ -27,8 +27,6 @@ namespace osu.Game.Online.API
private ConcurrentQueue<APIRequest> queue = new ConcurrentQueue<APIRequest>();
public readonly Scheduler Scheduler = new Scheduler();
/// <summary>
/// The username/email provided by the user when initiating a login.
/// </summary>
@ -306,27 +304,13 @@ namespace osu.Game.Online.API
Id = 1,
};
public void Update()
protected override void Dispose(bool isDisposing)
{
Scheduler.Update();
}
base.Dispose(isDisposing);
private void dispose()
{
config.Set(OsuSetting.Token, config.Get<bool>(OsuSetting.SavePassword) ? Token : string.Empty);
config.Save();
}
public void Dispose()
{
dispose();
GC.SuppressFinalize(this);
}
~APIAccess()
{
dispose();
}
}
public enum APIState

View File

@ -14,7 +14,7 @@ namespace osu.Game.Online.API
return request;
}
private void request_Progress(long current, long total) => API.Scheduler.Add(delegate { Progress?.Invoke(current, total); });
private void request_Progress(long current, long total) => Progress?.Invoke(current, total);
protected APIDownloadRequest()
{

View File

@ -1,13 +1,12 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Configuration;
using osu.Game.Users;
namespace osu.Game.Online.API
{
public interface IAPIProvider : IUpdateable
public interface IAPIProvider
{
/// <summary>
/// The local user.