diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 1ecad1bb71..bb72bdf02e 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -5,12 +5,14 @@ using System; using System.Collections.Concurrent; using System.Net; using System.Threading; +using osu.Framework; using osu.Framework.Logging; +using osu.Framework.Threading; using osu.Game.Online.API.Requests; namespace osu.Game.Online.API { - public class APIAccess + public class APIAccess : IUpdateable { private OAuth authentication; @@ -20,6 +22,8 @@ namespace osu.Game.Online.API ConcurrentQueue queue = new ConcurrentQueue(); + public Scheduler Scheduler = new Scheduler(); + public string Username; private SecurePassword password; @@ -273,5 +277,10 @@ namespace osu.Game.Online.API authentication.Clear(); State = APIState.Offline; } + + public void Update() + { + Scheduler.Update(); + } } } diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index 3eada96417..a63530ab79 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -74,17 +74,16 @@ namespace osu.Game.Online.API WebRequest.BlockingPerform(); - //OsuGame.Scheduler.Add(delegate { - Success?.Invoke(); - //}); + api.Scheduler.Add(delegate { Success?.Invoke(); }); } public void Fail(Exception e) { WebRequest?.Abort(); - //OsuGame.Scheduler.Add(delegate { + api.Scheduler.Add(delegate + { Failure?.Invoke(e); - //}); + }); } } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 8561c0124d..ec50314fdb 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -50,6 +50,12 @@ namespace osu.Game }); } + protected override void Update() + { + base.Update(); + API.Update(); + } + protected override void Dispose(bool isDisposing) { //refresh token may have changed.