user2000950
user2000950

Reputation: 561

Why does PhotonNetwork GetCustomRoomList fail after several connections?

I'm trying to create a custom lobby, and have players randomly fill rooms that have maxPlayers=2, the first 2 players connect and join a room but when the third player connects and calls GetCustomRoomList I get this error:

GetGameList failed: OperationResponse 217: ReturnCode: -2 (SQL logic error or missing database near "LIMIT": syntax error). Parameters: {}

What I'm doing is first attempting to join a random room inside that custom lobby, and if that fails, create a new room.

I start connecting like this:

TypedLobby lobbyData = new TypedLobby ("Proto01Lobby", LobbyType.SqlLobby);

PhotonNetwork.GameVersion = GAME_VERSION;
PhotonNetwork.ConnectUsingSettings ();

Then I try to join the random room:

public override void OnConnectedToMaster()
{
   Debug.Log ("Connetected!");
   PhotonNetwork.JoinRandomRoom (null, 2, MatchmakingMode.FillRoom, lobbyData, null, null);
}

IF that fails I try to get the list of rooms, to then create a unique room name based on the amount of rooms in the lobby:

public override void OnJoinRandomFailed(short returnCode, string message)
{
   Debug.Log ("Failed to connect to random room, Create a New Room");
   PhotonNetwork.GetCustomRoomList (lobbyData, null);
}

public override void OnRoomListUpdate (List<RoomInfo> roomList)
{
   Debug.Log ("Amount of rooms in lobbby: "+roomList.Count);
   string roomName = "CanvasProto" + roomList.Count;
   Debug.Log ("Create room: "+roomName);

   RoomOptions options = new RoomOptions ();
   options.MaxPlayers = 2;
   PhotonNetwork.CreateRoom(roomName, options, lobbyData, null);
}

But when the third player connects, he/she never reaches the OnRoomListUpdate because for some reason it fails.

Upvotes: 1

Views: 2353

Answers (1)

Tomer Shahar
Tomer Shahar

Reputation: 343

GetCustomRoomList fails because its trying to run an SQL query with null.

You need to add a query that filters the rooms you are trying to fetch.

If you want all rooms use GetRoomList().

I should warn you, if 2 players are in one room and 2 new players try to join, both will see that they need to create a new room and you my have to clients trying to create 2 rooms with the same name at the same time.

You will also not reuse room names for games that have finished.

Upvotes: -1

Related Questions