1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:47:24 +08:00

Simplify error handling of JoinRoom call

This commit is contained in:
Dean Herbert 2020-12-23 16:56:51 +09:00
parent d27b83d678
commit c3c3364d39

View File

@ -83,15 +83,19 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
{
Debug.Assert(room.RoomID.Value != null);
var joinTask = multiplayerClient.JoinRoom(room);
joinTask.ContinueWith(_ => Schedule(() => onSuccess?.Invoke(room)), TaskContinuationOptions.OnlyOnRanToCompletion);
joinTask.ContinueWith(t =>
multiplayerClient.JoinRoom(room).ContinueWith(t =>
{
PartRoom();
if (t.Exception != null)
Logger.Error(t.Exception, "Failed to join multiplayer room.");
Schedule(() => onError?.Invoke(t.Exception?.ToString() ?? string.Empty));
}, TaskContinuationOptions.NotOnRanToCompletion);
if (t.IsCompletedSuccessfully)
Schedule(() => onSuccess?.Invoke(room));
else
{
if (t.Exception != null)
Logger.Error(t.Exception, "Failed to join multiplayer room.");
PartRoom();
Schedule(() => onError?.Invoke(t.Exception?.ToString() ?? string.Empty));
}
});
}
private void updatePolling()