My game has options to join/create a random room or join/create a private room.
When joining a private room,I want to be able to check whether the room exists or not. if it doesn’t, then a message will be shown saying the “room doesn’t exist, please check the room name”.
Private rooms are invisible and not listed in the lobby, is there a way I could get a list of the invisible room names to check against the user input.
If you call PhotonNetwork.JoinRoom(string roomName) and joining fails, the method OnPhotonJoinRoomFailed() is called. It can fail to join if the room is either full or if the room doesn’t exist. You should be able to implement OnPhotonJoinRoomFailed() in your script to handle these cases.
I would like to be more specific as to why the player failed to join the room. As you mentioned, OnPhotonJoinRoomFailed() is called either when the room is full or doesn’t exist and these are two different things. I want to be more specific in my message to the player.
I am getting “IndexOutOfRangeException: Array index is out of range.” when using the code below.
void OnPhotonJoinRoomFailed (object[ ] reason) {
Debug.Log ( " message " + reason[1]);
}
Here is the example provided in the documentation:
//Example: void OnPhotonJoinRoomFailed(object[ ] codeAndMsg) { // codeAndMsg[0] is int ErrorCode. codeAndMsg[1] is string debug msg. }
That’s strange, according to the documentation that should work, I believe. I would check to make sure that reason[0] also gives an our of range error as well. I have no idea why it wouldn’t be passed the object array parameter correctly, though.
If you don’t get a helpful reply here, try posting your code and error message to Unity Answers or Photon’s forums at http://forum.exitgames.com/viewforum.php?f=17