"Connect() can't be called if peer not Disconnected"

Options
Alewinn
edited October 2011 in DotNet
Hi !

I have this warning raising just after i send a Peer.Disconnect(), when a user disconnects from the game then tryes to reconnect immediately. In this case the authentication sequence fails.
If the user re-tryes another time, he gets connected... It seems like the connection needs some time to release... or else, i don't know.

Server side the Log seems ok :
2011-10-03 12:53:45,821 [13] DEBUG Photon.SocketServer.PeerBase [(null)] - Peer 30 changed state from Connected to Disconnected
2011-10-03 12:53:45,821 [13] DEBUG Photon.SocketServer.PeerBase [(null)] - Peer 30 changed state from Connected to DisposeDisconnecting
2011-10-03 12:53:45,821 [13] DEBUG Photon.SocketServer.Rpc.Peer [(null)] - set operation handler to Photon.SocketServer.Rpc.OperationHandlerDisabled, was Klakos.WesternLords.AccountManagementPeer - peer id 30
2011-10-03 12:53:45,821 [13] DEBUG Photon.SocketServer.PeerBase [(null)] - Peer 30 changed state from Disconnected to Disposed

I wanted to know if i have to catch a feedback from the server before i Disconnect the peer, or is there some special considerations for having a clean disconnection sequence client side.

Comments

  • It's not suggested to reconnect immediately, because when you call peer.Disconnect(), the peer is not able to complete the disconnect operation immediately.
    The better way is to reconnect after receiving the "disconnect callback" in method PeerStatusCallBack(), like this:
    public override void PeerStatusCallBack(StatusCode statusCode)
    {
         switch (statusCode)
            {
                 case StatusCode.Disconnect:
                       peer.Connect();
                       break;
            }
    }
    
    If you're using Photon3 ,it's in OnStatusChanged() method.
  • Thanks a lot for this, I finally figured out why it didnt work ;
    In fact i use a different PhotonPeerListener depending of my network state client side.

    I just forgot to call Peer.Service() inside the state where the user arrives when authenticating :D