Skip to content

Commit

Permalink
Fix disposing of NetManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jul 8, 2024
1 parent f93e403 commit bd649d3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Fika.Core/Coop/Utils/NetManagerUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ public static void DestroyNetManager(bool isServer)
{
if (isServer)
{
Singleton<FikaServer>.Instance.NetServer.Stop();
Singleton<FikaServer>.TryRelease(Singleton<FikaServer>.Instance);
FikaServer server = Singleton<FikaServer>.Instance;
server.NetServer.Stop();
Singleton<FikaServer>.TryRelease(server);
GameObject.Destroy(server);
logger.LogInfo("Destroyed FikaServer");
}
else
{
Singleton<FikaClient>.Instance.NetClient.Stop();
Singleton<FikaClient>.TryRelease(Singleton<FikaClient>.Instance);
FikaClient client = Singleton<FikaClient>.Instance;
client.NetClient.Stop();
Singleton<FikaClient>.TryRelease(client);
GameObject.Destroy(client);
logger.LogInfo("Destroyed FikaClient");
}
}
Expand All @@ -75,10 +79,12 @@ public static void DestroyNetManager(bool isServer)
public static void DestroyPingingClient()
{
if (FikaGameObject != null)
{
Singleton<FikaPingingClient>.Instance.StopKeepAliveRoutine();
Singleton<FikaPingingClient>.Instance.NetClient.Stop();
Singleton<FikaPingingClient>.TryRelease(Singleton<FikaPingingClient>.Instance);
{
FikaPingingClient pingingClient = Singleton<FikaPingingClient>.Instance;
pingingClient.StopKeepAliveRoutine();
pingingClient.NetClient.Stop();
Singleton<FikaPingingClient>.TryRelease(pingingClient);
GameObject.Destroy(pingingClient);
logger.LogInfo("Destroyed FikaPingingClient");
}
}
Expand Down

0 comments on commit bd649d3

Please sign in to comment.