mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Move polling clients to osu.Game.Tests namespace
This commit is contained in:
35
osu.Game/Tests/PollingNotificationsClient.cs
Normal file
35
osu.Game/Tests/PollingNotificationsClient.cs
Normal file
@ -0,0 +1,35 @@
|
||||
// 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.
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Notifications;
|
||||
|
||||
namespace osu.Game.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// A notifications client which polls for new messages every second.
|
||||
/// </summary>
|
||||
public class PollingNotificationsClient : NotificationsClient
|
||||
{
|
||||
public PollingNotificationsClient(IAPIProvider api)
|
||||
: base(api)
|
||||
{
|
||||
}
|
||||
|
||||
public override Task ConnectAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
await API.PerformAsync(CreateFetchMessagesRequest());
|
||||
await Task.Delay(1000, cancellationToken);
|
||||
}
|
||||
}, cancellationToken);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user