[BUG] networkingPeer.State in offline mode incorrect on leaving room

Hi,

I am using PUN 1.9.1 and have auto join lobby switched off.

If I boot my game in offline mode, networkingPeer.State is initially set to ClientState.ConnectedToMaster. When I switch offlineMode off I correctly get the OnDisconnectedFromPhoton callback. All is right with the world.

If I enter a room and then leave that room, networkingPeer.State is set to ClientState.PeerCreated (in PhotonNtetwork::LeaveRoom()). When I switch offlineMode off I do NOT get the OnDisconnectedFromPhoton callback I expect to receive.

OnDisconnectedFromPhoton is never called in the second case because PhotonHandler::Update() early outs if networkingPeer.State equals ClientState.PeerCreated.

If I change PhotonNtetwork::LeaveRoom() to reset networkingPeer.State to ClientState.ConnectedToMaster instead, everything works as I expect. I'm not sure this fix would be right for all configurations/users though.

Does my fix sound OK to you guys?

Comments

  • My "fix" above causes issues when the network adapter is disabled. Exiting offline mode after joining and then leaving a room does not disconnect you at all, such that when you try and re-enable offline mode you hit the assert: "Can't start OFFLINE mode while connected!"

    I am now manually calling PhotonNetwork.Disconnect () before setting PhotonNetwork.offlineMode to false, this seems to give reliable behaviour in that I now get consistent calls to OnDisconnectedFromPhoton.

    I still think there is a bug here, seeing as setting offlineMode to true automatically connects you, setting it to false should disconnect you.