v1.2 - isMasterClient misbehaving?

I have a situation where 2 different clients in the same room as reporting themselves as masterclient. This seems really bad.

all i have to do is:

1. start a room on app instance 1
2. join that room on app instance 2.
3. leave room in app instance 2, disconnect from photon
4. reconnect to photon and rejoin same room with app instance 2
5. at that moment, in OnPhotonPlayerConnected on instance 1, instance 1 PhotonNetwork.isMasterClient = true. also OnJoinedRoom() on instance 2, PhotonNetwork.isMasterClient = true. thus both app instances are reporting that they are master client

Am I missing something? this seems really really bad.

Comments

  • i THINK this is the problem.
    in the below code, when you leave a room, masterclient gets set to yourself.
    and when you join a room, if the "masterclient" is still in the room, it leaves these variables alone, which of course is always going to be the case. can somebody please verify this change?

    private void LeftRoomCleanup()
    {
    this.mRoomToGetInto = null;
    this.mActors = new Dictionary<int, PhotonPlayer>();
    this.mMasterClient = null; //mLocalActor; // CHANGED. this appears to be a bug causing multiple clients reporting they are mster clients
    cachedInstantiations = new Hashtable();
    cachedRPCs = new Hashtable();
  • dreamoradreamora
    edited October 2011
    cleared to prevent confusion
  • How I came to this conclusion is watching the variable states.
    On first entering the lobby NetworkingPeer's mMasterClient == null.
    On entering the room, mMasterlient = the other player (ie the proper "server")
    On leaving the room, this code sets mMasterclient = mLocalActor
    Disconnecting from photon leaves it this way
    Reconnecting to photon and entering the lobby, this variable is still the local actor.
    on connection, this function gets called:

    void CheckMasterClient()
    {
    int lowestActorNumber = int.MaxValue;

    if (this.mMasterClient != null && this.mActors.ContainsKey(this.mMasterClient.ID))
    {
    // the current masterClient is still in the list of players, so it can't change););
    return;
    }


    the bolded code checks to see if the list of actors in the current room contains the curent mastersclient's ID.. and of course it does because it's set to "myself", and thus, fails to resolve the correct master client's id (which normally happens in the code below this snippet, on the first connection since mMasterClient = null at first)

    my change listed earlier in this thread fixes the problem I have, but I was looking for confirmation that this wouldn't cause other problems, since I"m obviously not familiar with the entire code base and flow.
  • Scritch,
    I will verify this asap but I think you are right. The masterclient is set to "myself" on leave and that doesn't make sense. While you're not in a room (you left, got disconnected, etc), the masterclient should be null and then re-set on entering and on leave (of current master).

    We will clean this up in the next update.
  • We discussed a solution before, so this is just to clean up:

    I just submitted v1.3 to the asset store. In it, MasterClient will become null when you leave a room. isMasterClient will work as expected, even outside of rooms.
    Hope this helps.
Sign In or Register to comment.