In lobby ,I want to join different room. How to create different room?

Hello,nice to see you! I am learning a CardGame,some difficulties around me.
I do this: first,i created a button and created a script for it.like this:
PhotonNetwork.JoinRandomRoom(roomchuji_customprp, 4, MatchmakingMode.FillRoom, LobbyType.SqlLobby, null, null);
public override void OnPhotonRandomJoinFailed(object[] codeAndMsg)
{
int roomnumber = Random.Range(100000, 900000);
string roomname = roomnumber.ToString();
RoomOptions roomoptions = new RoomOptions();
roomoptions.CustomRoomProperties = roomchuji_customprp;
roomoptions.CustomRoomPropertiesForLobby = new string[] { "roomname1" };
roomoptions.MaxPlayers = 4;
PhotonNetwork.JoinOrCreateRoom(roomname, roomoptions,LobbyType.SqlLobby);
}

a client create and join a room,another client create and join another room.
I want to know more explaination of the "JoinRandomRoom"and"JoinOrCreateRoom".

Answers

  • Hi @huizezgj,

    JoinRandomRoom tries to join a random room. If there is at least one room available, the client joins that room. If there isn't any room available, the callback OnPhotonRandomJoinFailed will be called. You already have that one. JoinOrCreateRoom tries to join a room with the given name. If the room (with the given name) is available the client joins this room. If the room is not available it will be created and the client will join it afterwards.
  • I has solved the problem,"roomoptions.CustomRoomPropertiesForLobby = new string[] { "roomname1" };"
    "roomname1" must be C0-C9.
  • huizezgj
    huizezgj
    edited March 2018
    Maybe I didn't say my problem clearly.But thank you!@Christian_Simon
  • Maybe I didn't say my problem clearly,but thank you!@Christian_Simon