Photon Automatically assigning Master(Looping issue), When MasterClient leave

In my app, I am manually assigning a user as Master using PhotonNetwork.SetMasterClient(PhotonNetwork.LocalPlayer); and inside OnMasterClientSwitched(Player newMasterClient) I am performing some functions. Everything works perfectly fine till here.

I have a check in place inside OnPlayerLeftRoom(), which checks whether the user that left was MasterClient or not, and if it was Master, then all the users should exit the session as well.

Problem: So, when NewMasterClient exists, Photon automatically assigns another user as master.

Kindly Help, I am stuck.

I want to know how I stop/prevent Photon from doing so.

Comments

  • Meep
    Meep ✭✭✭

    You can't stop this. It's required functionality and done by the server itself. PUN is especially reliant on there being a MasterClient in the room at all times since they are responsible for a lot of views and even those of players who are inactive. The newest MasterClient will always be the person with the next lowest ActorNumber.

    Store the ActorNumber of the current MasterClient in a field somewhere and compare it against the ActorNumber of the person leaving the room.

  • This was working before, but yesterday I made some changes to the code and now photon kept assigning Master to players (i dont know, why it was working before, due to glitch).

    Anyway, I just add value to PhotonNetwork.Room.SetCustomProperty("CurrentMaster"), (when I switch masterClient manually), and when current master leave, I implemented a check inside OnPlayerLeftRoom(Player otherPlayer) for that compare customProperty value with that of otherPlayer and if true, all users exit the session.

  • It was probably working before, because you were lucky with the timing.

    The server will automatically assign a new Master Client when someone leaves the room. This assigned Master Client may want to assign someone else if you really need this (it's best not to change the Master Client all that frequently)...

  • Your suggestions were very helpful, Thank you for your support.