Skip to content

Commit

Permalink
fix: stopping null ref caused by hud stopping non-active server
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Frowen committed May 23, 2021
1 parent 8c490e3 commit 8aa561a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Assets/Mirage/Components/NetworkManagerHud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ public void StartClientButtonHandler()
public void StopButtonHandler()
{
SetLabel(string.Empty);
NetworkManager.Server.Stop();
NetworkManager.Client.Disconnect();

if (NetworkManager.Server.Active)
NetworkManager.Server.Stop();
if (NetworkManager.Client.Active)
NetworkManager.Client.Disconnect();
OfflineSetActive();
}

Expand Down
2 changes: 2 additions & 0 deletions Assets/Mirage/Runtime/NetworkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ internal void OnAuthenticated(INetworkPlayer player)
/// </summary>
public void Disconnect()
{
// todo exit early if not active/initilzed

Player?.Connection?.Disconnect();
_disconnected?.Invoke();
Cleanup();
Expand Down
2 changes: 2 additions & 0 deletions Assets/Mirage/Runtime/NetworkServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public class NetworkServer : MonoBehaviour, INetworkServer
/// </summary>
public void Stop()
{
// todo exit early if not active/initilzed

if (LocalClient != null)
{
_onStopHost?.Invoke();
Expand Down

0 comments on commit 8aa561a

Please sign in to comment.