mirror of
https://github.com/osukey/osukey.git
synced 2025-05-05 21:57:24 +09: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.Collections.Concurrent;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
|
|
||||||
namespace osu.Game.Online.API
|
namespace osu.Game.Online.API
|
||||||
{
|
{
|
||||||
public class APIAccess
|
public class APIAccess : IUpdateable
|
||||||
{
|
{
|
||||||
private OAuth authentication;
|
private OAuth authentication;
|
||||||
|
|
||||||
@ -20,6 +22,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
ConcurrentQueue<APIRequest> queue = new ConcurrentQueue<APIRequest>();
|
ConcurrentQueue<APIRequest> queue = new ConcurrentQueue<APIRequest>();
|
||||||
|
|
||||||
|
public Scheduler Scheduler = new Scheduler();
|
||||||
|
|
||||||
public string Username;
|
public string Username;
|
||||||
|
|
||||||
private SecurePassword password;
|
private SecurePassword password;
|
||||||
@ -273,5 +277,10 @@ namespace osu.Game.Online.API
|
|||||||
authentication.Clear();
|
authentication.Clear();
|
||||||
State = APIState.Offline;
|
State = APIState.Offline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
Scheduler.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,17 +74,16 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
WebRequest.BlockingPerform();
|
WebRequest.BlockingPerform();
|
||||||
|
|
||||||
//OsuGame.Scheduler.Add(delegate {
|
api.Scheduler.Add(delegate { Success?.Invoke(); });
|
||||||
Success?.Invoke();
|
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Fail(Exception e)
|
public void Fail(Exception e)
|
||||||
{
|
{
|
||||||
WebRequest?.Abort();
|
WebRequest?.Abort();
|
||||||
//OsuGame.Scheduler.Add(delegate {
|
api.Scheduler.Add(delegate
|
||||||
|
{
|
||||||
Failure?.Invoke(e);
|
Failure?.Invoke(e);
|
||||||
//});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,12 @@ namespace osu.Game
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
API.Update();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
//refresh token may have changed.
|
//refresh token may have changed.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user