Add very basic connection status logging for spectator streaming client

This commit is contained in:
Dean Herbert 2020-11-02 17:32:10 +09:00
parent 1ab609fa2f
commit a89aeaf1ce
1 changed files with 11 additions and 2 deletions

View File

@ -13,6 +13,7 @@
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 @@ private async Task connect()
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 @@ async Task tryUntilConnected()
break;
}
catch
catch (Exception e)
{
Logger.Log($"Spectator client connection error: {e}", LoggingTarget.Network);
await Task.Delay(5000);
}
}