1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 16:22:55 +08:00

Merge pull request #10658 from peppy/spectator-connection-logging

Add very basic connection status logging for spectator streaming client
This commit is contained in:
Bartłomiej Dach 2020-11-02 20:59:04 +01:00 committed by GitHub
commit 2d1db6a22d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ using Newtonsoft.Json;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Replays.Legacy;
@ -122,19 +123,26 @@ namespace osu.Game.Online.Spectator
isConnected = false;
playingUsers.Clear();
if (ex != null) await tryUntilConnected();
if (ex != null)
{
Logger.Log($"Spectator client lost connection: {ex}", LoggingTarget.Network);
await tryUntilConnected();
}
};
await tryUntilConnected();
async Task tryUntilConnected()
{
Logger.Log("Spectator client connecting...", LoggingTarget.Network);
while (api.State.Value == APIState.Online)
{
try
{
// reconnect on any failure
await connection.StartAsync();
Logger.Log("Spectator client connected!", LoggingTarget.Network);
// success
isConnected = true;
@ -151,8 +159,9 @@ namespace osu.Game.Online.Spectator
break;
}
catch
catch (Exception e)
{
Logger.Log($"Spectator client connection error: {e}", LoggingTarget.Network);
await Task.Delay(5000);
}
}