Create Room/Join Room Issue
Options
Hi,
When using PhotonNetwork.CreateRoom, if the room exists a debug message is fired.
Is it possible to get the client to connect to the room automatically if the room already exists? As I am trying to connect two players to a 1v1 room.
I would imagine that there would be a method called something like "PhotonNetwork.DoesRoomExist()" but I cant find anything that does this.
I tried rolling my own, but I think that the room list is not getting updated fast enough and then both clients try and create a room. Which then causes one of them not to connect as the room now exists.
[code2=csharp]bool found = false;
foreach(RoomInfo room in PhotonNetwork.GetRoomList()){
if(room.name == roomName){
found = true;
PhotonNetwork.JoinRoom(room);
break;
}
}
if(!found)
PhotonNetwork.CreateRoom(roomName,true,true,2);[/code2]
What is the correct way to handle this problem?
Thanks,
David
When using PhotonNetwork.CreateRoom, if the room exists a debug message is fired.
"createGame failed, client stays on masterserver: OperationResponse 227: ReturnCode: 32766 (A game with the specified id already exist.). Parameters: {}."
Is it possible to get the client to connect to the room automatically if the room already exists? As I am trying to connect two players to a 1v1 room.
I would imagine that there would be a method called something like "PhotonNetwork.DoesRoomExist()" but I cant find anything that does this.
I tried rolling my own, but I think that the room list is not getting updated fast enough and then both clients try and create a room. Which then causes one of them not to connect as the room now exists.
[code2=csharp]bool found = false;
foreach(RoomInfo room in PhotonNetwork.GetRoomList()){
if(room.name == roomName){
found = true;
PhotonNetwork.JoinRoom(room);
break;
}
}
if(!found)
PhotonNetwork.CreateRoom(roomName,true,true,2);[/code2]
What is the correct way to handle this problem?
Thanks,
David
0
Comments
-
This is not only a log message but a error that's handled in OnOperationResponse(). PUN calls OnPhotonCreateRoomFailed() which you can implement anywhwere. In your implementation you could then try to join the room.
Also read this on matchmaking, just in case:
http://doc.exitgames.com/photon-cloud/M ... gAndLobby/0 -
Excellent this is exactly what I needed.
Thanks again.0