1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Use extension method in all call sites of fire-and-forget async usage

This commit is contained in:
Dean Herbert 2020-12-23 17:10:34 +09:00
parent 1864da00e6
commit 7cc38f03d1
7 changed files with 17 additions and 11 deletions

View File

@ -1,4 +1,4 @@
// 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.
#nullable enable
@ -14,6 +14,7 @@ using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
@ -84,7 +85,7 @@ namespace osu.Game.Online.RealtimeMultiplayer
if (!connected.NewValue)
{
Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important);
LeaveRoom();
LeaveRoom().FireAndForget();
}
});
}

View File

@ -7,6 +7,7 @@ using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Online.API;
@ -105,13 +106,13 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Match
return;
if (localUser.State == MultiplayerUserState.Idle)
Client.ChangeState(MultiplayerUserState.Ready);
Client.ChangeState(MultiplayerUserState.Ready).FireAndForget(true);
else
{
if (Room?.Host?.Equals(localUser) == true)
Client.StartMatch();
Client.StartMatch().FireAndForget(true);
else
Client.ChangeState(MultiplayerUserState.Idle);
Client.ChangeState(MultiplayerUserState.Idle).FireAndForget(true);
}
}

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
@ -176,7 +177,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Participants
if (Room.Host?.UserID != api.LocalUser.Value.Id)
return;
Client.TransferHost(targetUser);
Client.TransferHost(targetUser).FireAndForget(true);
})
};
}

View File

@ -58,7 +58,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
client.ChangeSettings(item: item).ContinueWith(t =>
{
return Schedule(() =>
Schedule(() =>
{
loadingLayer.Hide();

View File

@ -4,6 +4,7 @@
using osu.Framework.Allocation;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Extensions;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.RealtimeMultiplayer;
using osu.Game.Screens.Multi.Components;
@ -21,7 +22,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
base.OnResuming(last);
if (client.Room != null)
client.ChangeState(MultiplayerUserState.Idle);
client.ChangeState(MultiplayerUserState.Idle).FireAndForget(true);
}
protected override void UpdatePollingRate(bool isIdle)

View File

@ -56,8 +56,8 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
}
}, true);
client.ChangeState(MultiplayerUserState.Loaded).ContinueWith(task =>
failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion);
client.ChangeState(MultiplayerUserState.Loaded)
.ContinueWith(task => failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion);
if (!startedEvent.Wait(TimeSpan.FromSeconds(30)))
failAndBail("Failed to start the multiplayer match in time.");

View File

@ -8,6 +8,7 @@ using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Logging;
using osu.Game.Extensions;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.RoomStatuses;
using osu.Game.Online.RealtimeMultiplayer;
@ -68,7 +69,8 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
var joinedRoom = JoinedRoom.Value;
base.PartRoom();
multiplayerClient.LeaveRoom();
multiplayerClient.LeaveRoom().FireAndForget();
// Todo: This is not the way to do this. Basically when we're the only participant and the room closes, there's no way to know if this is actually the case.
// This is delayed one frame because upon exiting the match subscreen, multiplayer updates the polling rate and messes with polling.