Skip to content

Commit

Permalink
fix: Cleanup after PR #3935
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGadget1024 committed Oct 29, 2024
1 parent af133e6 commit f615248
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Assets/Mirror/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ public virtual void OnDestroy()
// don't use this anymore.
// fixes: https://github.com/MirrorNetworking/Mirror/issues/2802
// DEPRECATED 2024-10-29
[Obsolete("Override OnDestroy instead of OnApplicationQuit. Fixes: https://github.com/MirrorNetworking/Mirror/issues/2802")]
[Obsolete("Override OnDestroy instead of OnApplicationQuit.")]
public virtual void OnApplicationQuit() {}

/// <summary>The name of the current network scene.</summary>
Expand Down
9 changes: 7 additions & 2 deletions Assets/Mirror/Core/Transport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ public virtual void ServerLateUpdate() {}
/// <summary>Shut down the transport, both as client and server</summary>
public abstract void Shutdown();

/// <summary>Called by Unity when quitting. Inheriting Transports should call base for proper Shutdown.</summary>
// use OnDestroy instead of OnApplicationQuit:
// [Obsolete] in case someone is inheriting it.
// don't use this anymore.
// fixes: https://github.com/MirrorNetworking/Mirror/issues/2802
// DEPRECATED 2024-10-29
[Obsolete("Override OnDestroy instead of OnApplicationQuit.")]
public virtual void OnApplicationQuit() {}

// fixes: https://github.com/MirrorNetworking/Mirror/issues/2802
public virtual void OnDestroy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public void SetServerLobbyParams(LobbyCreateRequest request)
_request = request;
}

private void OnDestroy()
public override void OnDestroy()
{
// attempt to clean up lobbies, if active
if (NetworkServer.active)
Expand All @@ -340,6 +340,8 @@ private void OnDestroy()
// sorry. this can go once the lobby service can timeout lobbies itself
Thread.Sleep(300);
}

base.OnDestroy();
}
}
}
5 changes: 2 additions & 3 deletions Assets/Mirror/Transports/Threaded/ThreadedTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,10 @@ void EnsureThread()
Debug.Log($"ThreadedTransport: started worker thread!");
}

protected virtual void OnDestroy()
public override void OnDestroy()
{
// stop thread fully
Shutdown();

base.OnDestroy();
// TODO recycle writers.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ public class #SCRIPTNAME# : NetworkManager
base.ConfigureHeadlessFrameRate();
}

/// <summary>
/// called when quitting the application by closing the window / pressing stop in the editor
/// </summary>
public override void OnApplicationQuit()
{
base.OnApplicationQuit();
}

#endregion

#region Scene Management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public class #SCRIPTNAME# : NetworkManager
public event Action OnStartAction;
public event Action OnDestroyAction;

public event Action OnApplicationQuitAction;

public event Action<string> ServerChangeSceneAction;
public event Action<string> OnServerChangeSceneAction;
public event Action<string> OnServerSceneChangedAction;
Expand Down Expand Up @@ -117,15 +115,6 @@ public class #SCRIPTNAME# : NetworkManager
base.ConfigureHeadlessFrameRate();
}

/// <summary>
/// called when quitting the application by closing the window / pressing stop in the editor
/// </summary>
public override void OnApplicationQuit()
{
OnApplicationQuitAction?.Invoke();
base.OnApplicationQuit();
}

#endregion

#region Scene Management
Expand Down

0 comments on commit f615248

Please sign in to comment.