mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Add ServerShuttingDownCountdown
This commit is contained in:
@ -18,6 +18,7 @@ using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Multiplayer.Countdown;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Rooms.RoomStatuses;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Utils;
|
||||
@ -26,6 +27,8 @@ namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
public abstract class MultiplayerClient : Component, IMultiplayerClient, IMultiplayerRoomServer
|
||||
{
|
||||
public Action<Notification>? PostNotification { protected get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when any change occurs to the multiplayer room.
|
||||
/// </summary>
|
||||
@ -554,6 +557,14 @@ namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
case CountdownStartedEvent countdownStartedEvent:
|
||||
Room.ActiveCountdowns.Add(countdownStartedEvent.Countdown);
|
||||
|
||||
switch (countdownStartedEvent.Countdown)
|
||||
{
|
||||
case ServerShuttingDownCountdown:
|
||||
postServerShuttingDownNotification();
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CountdownStoppedEvent countdownStoppedEvent:
|
||||
@ -569,6 +580,21 @@ namespace osu.Game.Online.Multiplayer
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void postServerShuttingDownNotification()
|
||||
{
|
||||
ServerShuttingDownCountdown? countdown = room?.ActiveCountdowns.OfType<ServerShuttingDownCountdown>().FirstOrDefault();
|
||||
|
||||
if (countdown == null)
|
||||
return;
|
||||
|
||||
PostNotification?.Invoke(new SimpleNotification
|
||||
{
|
||||
Text = countdown.FinalNotification
|
||||
? $"The multiplayer server is restarting in {countdown.TimeRemaining:hh\\:mm\\:ss}. This multiplayer room will be closed shortly."
|
||||
: $"The multiplayer server is restarting in {countdown.TimeRemaining:hh\\:mm\\:ss}."
|
||||
});
|
||||
}
|
||||
|
||||
Task IMultiplayerClient.UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability)
|
||||
{
|
||||
Scheduler.Add(() =>
|
||||
|
@ -13,6 +13,7 @@ namespace osu.Game.Online.Multiplayer
|
||||
[MessagePackObject]
|
||||
[Union(0, typeof(MatchStartCountdown))] // IMPORTANT: Add rules to SignalRUnionWorkaroundResolver for new derived types.
|
||||
[Union(1, typeof(ForceGameplayStartCountdown))]
|
||||
[Union(2, typeof(ServerShuttingDownCountdown))]
|
||||
public abstract class MultiplayerCountdown
|
||||
{
|
||||
/// <summary>
|
||||
|
20
osu.Game/Online/Multiplayer/ServerShuttingDownCountdown.cs
Normal file
20
osu.Game/Online/Multiplayer/ServerShuttingDownCountdown.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// 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 MessagePack;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// A countdown that indicates the current multiplayer server is shutting down.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class ServerShuttingDownCountdown : MultiplayerCountdown
|
||||
{
|
||||
/// <summary>
|
||||
/// If this is the final notification, no more <see cref="ServerShuttingDownCountdown"/> events will be sent after this.
|
||||
/// </summary>
|
||||
[Key(2)]
|
||||
public bool FinalNotification { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user