GetRoomList not working

Options
Hello,
Today I was trying to getRoomList but it's not working
I make If the room exist then make another room but its not work , it give me it's doesn't exist and when make a room give me error " Operation failed: OperationResponse 227: ReturnCode: 32766 (A game with the specified id already exist.). Parameters: {} Server: MasterServer "

this is the code
private void RoomCheck(string CheckName  , string ElseName) {
	OnReceivedRoomListUpdate();
List<RoomInfo> roomList = PhotonNetwork.GetRoomList().ToList();
RoomInfo room  = roomList.FirstOrDefault(r => r.Name == CheckName);
bool exists = (room != null);
Debug.Log(exists);
if (exists == false ) {
var RoomOptions = new  RoomOptions {MaxPlayers = 1 , IsOpen = true , isVisible = true};
	PhotonNetwork.CreateRoom(CheckName,RoomOptions,null);
} else if (exists == true) {
	var RoomOptions = new  RoomOptions {MaxPlayers = 1 , IsOpen = true , isVisible = true};
	PhotonNetwork.CreateRoom(ElseName,RoomOptions,null);
} 
}
and this is OnReceivedRoomListUpdate

public override void OnReceivedRoomListUpdate() 
{
List<RoomInfo> roomList = PhotonNetwork.GetRoomList().ToList();
} 

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Anteeiiku,

    Thank you for choosing Photon!

    We do not recommend this approach.
    Why do you need to create rooms with a specific name?

    What we recommend is:
    Try to find a room matching the criteria you want, if not found, create a new one.
    Giving an explicit name to a room is optional.

    Besides, PhotonNetwork.GetRoomList() should give correct result (cached rooms list) after the OnReceivedRoomListUpdate() callback is triggered automatically by PUN (and not explicitly called by your code like in your example). That is why we usually recommend using PhotonNetwork.GetRoomList() inside the callback itself.
  • Hello @JohnTube ,
    thank you but that's what I tried to do , but I fixed the problem by connect to lobby * I forget to do * .

    and I hope to see setup for Pun 2 ... Thanks <3
  • But I have question , If I have 5 Rooms and I wanna to check room number 3 isn't open
    How I can do this ?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Anteeiiku,

    You need to keep a cached updated list of rooms in the lobby.
    Get the room by index or name and check it's RoomInfo.IsOpen to know if it's open or not.