Add assertions against null reference for connection usages

This commit is contained in:
Dean Herbert
2022-02-15 13:40:58 +09:00
parent 60153bb69d
commit 28b45fa899
2 changed files with 40 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#nullable enable
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR.Client;
using osu.Framework.Allocation;
@ -51,6 +52,8 @@ namespace osu.Game.Online.Spectator
if (!IsConnected.Value)
return Task.CompletedTask;
Debug.Assert(connection != null);
return connection.SendAsync(nameof(ISpectatorServer.BeginPlaySession), state);
}
@ -59,6 +62,8 @@ namespace osu.Game.Online.Spectator
if (!IsConnected.Value)
return Task.CompletedTask;
Debug.Assert(connection != null);
return connection.SendAsync(nameof(ISpectatorServer.SendFrameData), data);
}
@ -67,6 +72,8 @@ namespace osu.Game.Online.Spectator
if (!IsConnected.Value)
return Task.CompletedTask;
Debug.Assert(connection != null);
return connection.SendAsync(nameof(ISpectatorServer.EndPlaySession), state);
}
@ -75,6 +82,8 @@ namespace osu.Game.Online.Spectator
if (!IsConnected.Value)
return Task.CompletedTask;
Debug.Assert(connection != null);
return connection.SendAsync(nameof(ISpectatorServer.StartWatchingUser), userId);
}
@ -83,6 +92,8 @@ namespace osu.Game.Online.Spectator
if (!IsConnected.Value)
return Task.CompletedTask;
Debug.Assert(connection != null);
return connection.SendAsync(nameof(ISpectatorServer.EndWatchingUser), userId);
}
}