When I am testing my multiplayer game in the editor using the new multiplayer SDK with NGO, whenever I normally leave a session, I have a callback for NGO ClientStopped where I remove the player from the session, so that it will not leave an empty session in the sessions list.
private async void ClientStopped(bool host)
{
if (session != null)
{
await session.LeaveAsync();
session = null;
}
}
This works in the normal build, but when I’m in the editor, if I try quitting while connected by clicking the stop button in the editor, it will give this error:
ObjectDisposedException: Cannot access a disposed object.
Object name: '$lobby!!!pbenVaYbwj657a8Gxyu8na!!!b60226d4-5d39-4f13-8379-2b254a35f88b!!!cf0992d2-36e3-44bd-a060-8492a9cc4aaa'.
Unity.Services.Wire.Internal.Subscription.UnsubscribeAsync () (at ./Library/PackageCache/com.unity.services.wire@098672f918fa/Runtime/Centrifuge/Subscription.cs:196)
Unity.Services.Lobbies.Internal.LobbyChannel.UnsubscribeAsync () (at ./Library/PackageCache/com.unity.services.multiplayer@e7b9f7939c7c/Runtime/Lobbies/SDK/LobbyUpdates/Internal/LobbyChannel.cs:70)
Unity.Services.Multiplayer.LobbyHandler.LobbyUnsubscribeCallbacksAsync () (at ./Library/PackageCache/com.unity.services.multiplayer@e7b9f7939c7c/Runtime/Multiplayer/Lobby/LobbyHandler.cs:238)
Unity.Services.Multiplayer.LobbyHandler.ResetAsync () (at ./Library/PackageCache/com.unity.services.multiplayer@e7b9f7939c7c/Runtime/Multiplayer/Lobby/LobbyHandler.cs:774)
Unity.Services.Multiplayer.SessionHandler.LeaveAsync () (at ./Library/PackageCache/com.unity.services.multiplayer@e7b9f7939c7c/Runtime/Multiplayer/Session/SessionHandler.cs:593)
CustomNetworkManager.ClientStopped (System.Boolean host) (at Assets/Scripts/Infrastructure/CustomNetworkManager.cs:136)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <191a1970a53948f9819ac1d2e4f5c72e>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <84f0d810adef4e6c8deab33e4ae93f7c>:0)
UnityEngine.UnitySynchronizationContext.Exec () (at <84f0d810adef4e6c8deab33e4ae93f7c>:0)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at <84f0d810adef4e6c8deab33e4ae93f7c>:0)