How to know client disconnected from server

xzlxt720
xzlxt720 ✭✭
edited January 2012 in Photon Server
How do I know this client is disconnected from the server, which function to use?

Comments

  • To know if a client has disconnected use
    protected override void OnDisconnect()
            {
                // Handles the clients disconnect from the server
                Log.Info("Client disconnected");
            }
    

    I have that in my Class file that inheriets from the PeerBase.
  • There is another question, if I write the code as follows
    protected override void OnDisconnect()
            {
                Log.WarnFormat("{0}:{1} OnDisconnect", this.RemoteIP, this.RemotePort);
            }
    
    it always print 127.0.0.1:0, why this.RemotePort always zero ?
  • The values are reset to defaults when the connection ends. Unluckily, this happens before OnDisconnect is called.
    I guess you want to use this info for debugging purposes only?
  • I want to know that which peer is not in my expected cases disconnect, Calculating the number of online peer interval some time