Removing a player from the lobby

I’m designing a simple multiplayer game with Normcore, and I was wondering whether this is an adequate method of removing players from the lobby?

I’ve tested it a few times now, and occasionally the lobby states that the player is still in the lobby, even after their game instance has been closed.

    // removes the local player from the lobby
    private async void OnDestroy()
    {

        string identity = AuthenticationService.Instance.PlayerId;
        await LobbyService.Instance.RemovePlayerAsync(code, identity);

    }

That should be good enough. Are you not seeing any unhandled errors in the log when that occurs?

When you say “the lobby states that the player is still in the lobby” are you referring to a different client that’s in the same lobby?

Sorry for necroing this, but I have a similar where when I press my matchmake button, I find a MatchIdAssignment, use this MatchId to CreateOrJoinLobby for both my players and sometimes they join their last lobby where the HostId is the old Id of one of my players even though I always remove my players from the lobby they are in on the OnDisable of my script which I always see the log… It’s slowing me so much I always end up in the old lobby even though I try to create a new one with a completely new MatchId everytime… Any idea?