MasterClient, Creating Rooms Newb?

Options

Hi there,
another day of gaining inches, not miles as a newb multi player dev, with photon.

here are some questions that have come up today. If you can, please answer what you can.


a) using autoJoinLobby = true, at OnJoinedLobby(), I initiate a check on to see if anyone else is in the room (PhotonNetwork.otherPlayers.Length). If this number hits 1, then I know someone else has entered the room, and thus, can proceed to load a common level.

However, when running the standalone and the editor, no "other player", ever enters the room. They are internally separate. ???




b) Trying a slightly different approach, I decided to create a room, instead of the lobby, however this is even worse in its results. Using the return OnConnectedToMaster(), I create a room. I realize in its current form not checking if isMasterClient is an issue. But for now, I left it out since my check if(isMasterClient), never returned true after connecting.

So, 1) how is isMasterClient set? I thought it was the first player to arrive on the scene. No?

2) back to the next issue, OnConnectedToMaster(), for testing purposes, I decided to create a room with a few custom, RoomOptions, isOpen, isVisible and maxPlayers. I create the room....
Code (csharp):

print(":::connectedtomaster");
print(":::isMasterClient=" + PhotonNetwork.isMasterClient);
print(":::themasterclientis" + PhotonNetwork.masterClient);
RoomOptions roomOptions = new RoomOptions();
roomOptions.CleanupCacheOnLeave = true;
roomOptions.isOpen = true;
roomOptions.isVisible = true;
roomOptions.maxPlayers = 2;
PhotonNetwork.CreateRoom ("lobby25", roomOptions, TypedLobby.Default);
print("ROOMCREATED::");
checkRoomCreated();


Now, again for testing I want to check the room. I am thinking that this process can be used by non masterClient players, to see if it fits their criteria.
Code (csharp):

void checkRoomCreated(){
List roomInfoList = new List(PhotonNetwork.GetRoomList());
print("rilc" + roomInfoList.Count);
for(int i = 0; i < roomInfoList.Count; i++){
print("ril" + i + "n" + roomInfoList[i].name);
print("ril" + i + "m" + roomInfoList[i].maxPlayers);
}
}

However, the result is, that the roomInfoList, has a count of 0. So, how can I check??




Thanks for any help.
Rennie

Comments

  • Hi Renman3000,

    a) using autoJoinLobby = true, at OnJoinedLobby(), I initiate a check on to see if anyone else is in the room (PhotonNetwork.otherPlayers.Length). If this number hits 1, then I know someone else has entered the room, and thus, can proceed to load a common level.


    I'm not sure if you are messing up with the lobby and the room here. When OnJoinedLobby() is called, you are inside the lobby, not inside any room. While in the lobby you can get a room list containing all rooms, which are currently active and join one of these. However when joining any room, you are automatically leaving the lobby.

    So, 1) how is isMasterClient set? I thought it was the first player to arrive on the scene. No?


    The scene has nothing to do with how the Master Client is determined. The Master Client is always the player, who created and joined the room first. When the Master Client leaves, his 'attributes' are passed to another client, who is inside the room.

    However, the result is, that the roomInfoList, has a count of 0. So, how can I check??


    I guess it is because the room doesn't exist when you check this using the code above. Reason for this: You are creating the room and try to check it instantly. This doesn't work since CreateRoom needs to message the server which have some latency. So when your code tries to receive a room list, the message to create the room might possibly not even send, so there is no room available. You can use the OnCreatedRoom() callback to make sure, that your room is created. Starting at this point you can receive a 'working' room list.

    Hopefully this answers your questions. If not feel free to ask some more.