1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 21:53:21 +08:00
osu-lazer/osu.Game/Tests/PollingNotificationsClient.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.0 KiB
C#
Raw Normal View History

// 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)
{
2022-11-21 14:22:57 +08:00
await API.PerformAsync(CreateInitialFetchRequest());
await Task.Delay(1000, cancellationToken);
}
}, cancellationToken);
return Task.CompletedTask;
}
}
}