mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 06:12:55 +08:00
Fix API scheduling.
This commit is contained in:
parent
b4e65e7011
commit
154b914a3a
@ -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<APIRequest> queue = new ConcurrentQueue<APIRequest>();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
//});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user