mirror of
https://github.com/ppy/osu.git
synced 2024-11-08 20:17:27 +08:00
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
// 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;
|
|
using System.Collections.Generic;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Game.Online;
|
|
using osu.Game.Online.API;
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
namespace osu.Game.Screens.Multi.Components
|
|
{
|
|
public abstract class RoomPollingComponent : PollingComponent
|
|
{
|
|
public Action<List<Room>> RoomsReceived;
|
|
|
|
/// <summary>
|
|
/// The time in milliseconds to wait between polls.
|
|
/// Setting to zero stops all polling.
|
|
/// </summary>
|
|
public new readonly Bindable<double> TimeBetweenPolls = new Bindable<double>();
|
|
|
|
public IBindable<bool> InitialRoomsReceived => initialRoomsReceived;
|
|
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
|
|
|
|
[Resolved]
|
|
protected IAPIProvider API { get; private set; }
|
|
|
|
protected RoomPollingComponent()
|
|
{
|
|
TimeBetweenPolls.BindValueChanged(time => base.TimeBetweenPolls = time.NewValue);
|
|
}
|
|
|
|
protected void NotifyRoomsReceived(List<Room> rooms)
|
|
{
|
|
initialRoomsReceived.Value = true;
|
|
RoomsReceived?.Invoke(rooms);
|
|
}
|
|
}
|
|
}
|