Master client switch

Hello!

Is anyone else having problems with Master client not being switched to another player (when Master disconnects)?

thanks,
Slav

Comments

  • I'm not sure if this worked before (or why it is broken in my case).

    The issue was that mMasterClient didn't become null (that's why I check if its ID is in the list of actors - this seems to help to fix the issue).
    void CheckMasterClient()
        {
    
            Debug.Log("check master client!");
            int oldID = -1;
            bool changed = false;
            if (mMasterClient != null)
            {
               //ADDITIONAL CHECK:
                foreach (KeyValuePair<int, PhotonPlayer> entry in mActors)
                {
                    if (entry.Value.ID == mMasterClient.ID)
                    {
                        Debug.Log("master client is in the list of actors (OK)!");
                        oldID = mMasterClient.ID;
                        break;
                    }
                }
            }
    
            foreach (KeyValuePair<int, PhotonPlayer> entry in mActors)
            {
                Debug.Log("entry value ID: "+entry.Value.ID + " oldID: "+ oldID);
                if (entry.Value.ID < oldID || oldID == -1)
                {
                    changed = true;
                    mMasterClient = entry.Value;
                    oldID = mMasterClient.ID;
                }
            }
    
            if (changed)
            {
                Debug.Log("master client changed! "+mMasterClient);
                SendMonoMessage("OnMasterClientSwitched", mMasterClient);
            }
        }
    
  • I'm having the same issue. Where exactly do I have to put this code? Thanks.
  • did you check against a real photon 3.0 RC3 server instead of the one that comes with the package and see if that fixes it? Just start the loadbalancing instance on photon and you are fine to go with PUN
  • This is (meanwhile) a known bug in the Photon Unity Networking plugin.
    The update is almost ready and will go live within the next days. We will post about this update in the Unity forum, here and in the blog, so you easily know when it's up.
  • tutibueno wrote:
    I'm having the same issue. Where exactly do I have to put this code? Thanks.
    This is a replacement for a method located in NetworkingPeer.cs