mirror of
https://github.com/osukey/osukey.git
synced 2025-05-06 22:27:25 +09:00
Use extension method in all call sites of fire-and-forget async usage
This commit is contained in:
parent
1864da00e6
commit
7cc38f03d1
@ -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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
@ -14,6 +14,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
@ -84,7 +85,7 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
if (!connected.NewValue)
|
if (!connected.NewValue)
|
||||||
{
|
{
|
||||||
Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important);
|
Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important);
|
||||||
LeaveRoom();
|
LeaveRoom().FireAndForget();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using JetBrains.Annotations;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -105,13 +106,13 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Match
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (localUser.State == MultiplayerUserState.Idle)
|
if (localUser.State == MultiplayerUserState.Idle)
|
||||||
Client.ChangeState(MultiplayerUserState.Ready);
|
Client.ChangeState(MultiplayerUserState.Ready).FireAndForget(true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Room?.Host?.Equals(localUser) == true)
|
if (Room?.Host?.Equals(localUser) == true)
|
||||||
Client.StartMatch();
|
Client.StartMatch().FireAndForget(true);
|
||||||
else
|
else
|
||||||
Client.ChangeState(MultiplayerUserState.Idle);
|
Client.ChangeState(MultiplayerUserState.Idle).FireAndForget(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Cursor;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -176,7 +177,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer.Participants
|
|||||||
if (Room.Host?.UserID != api.LocalUser.Value.Id)
|
if (Room.Host?.UserID != api.LocalUser.Value.Id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Client.TransferHost(targetUser);
|
Client.TransferHost(targetUser).FireAndForget(true);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
|
|
||||||
client.ChangeSettings(item: item).ContinueWith(t =>
|
client.ChangeSettings(item: item).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
return Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
loadingLayer.Hide();
|
loadingLayer.Hide();
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.RealtimeMultiplayer;
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
using osu.Game.Screens.Multi.Components;
|
using osu.Game.Screens.Multi.Components;
|
||||||
@ -21,7 +22,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
|
|
||||||
if (client.Room != null)
|
if (client.Room != null)
|
||||||
client.ChangeState(MultiplayerUserState.Idle);
|
client.ChangeState(MultiplayerUserState.Idle).FireAndForget(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdatePollingRate(bool isIdle)
|
protected override void UpdatePollingRate(bool isIdle)
|
||||||
|
@ -56,8 +56,8 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
client.ChangeState(MultiplayerUserState.Loaded).ContinueWith(task =>
|
client.ChangeState(MultiplayerUserState.Loaded)
|
||||||
failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion);
|
.ContinueWith(task => failAndBail(task.Exception?.Message ?? "Server error"), TaskContinuationOptions.NotOnRanToCompletion);
|
||||||
|
|
||||||
if (!startedEvent.Wait(TimeSpan.FromSeconds(30)))
|
if (!startedEvent.Wait(TimeSpan.FromSeconds(30)))
|
||||||
failAndBail("Failed to start the multiplayer match in time.");
|
failAndBail("Failed to start the multiplayer match in time.");
|
||||||
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Multiplayer.RoomStatuses;
|
using osu.Game.Online.Multiplayer.RoomStatuses;
|
||||||
using osu.Game.Online.RealtimeMultiplayer;
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
@ -68,7 +69,8 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
var joinedRoom = JoinedRoom.Value;
|
var joinedRoom = JoinedRoom.Value;
|
||||||
|
|
||||||
base.PartRoom();
|
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.
|
// 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.
|
// This is delayed one frame because upon exiting the match subscreen, multiplayer updates the polling rate and messes with polling.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user