Getting Room Properties

edited January 2013 in Flash (deprecated)
Hi There,

I'm really struggling to access the game properties of a specific game in the "games list" from within the lobby.

Essentially I need to check if the game is open or visible before attempting to join it. Otherwise I want to create a new game.

I have the below which just doesn't want to work:

//// these work:
var GamesList:Vector.<GameListEntry> = PhotonPeer.getInstance().getGameList();
var GameToJoin = GamesList[0].roomName

//// this is the line that breaks.....
var gp:GameProperties = PhotonPeer.getInstance().opGetGameProperties(GameToJoin);

The above doesn't work but I don't know the correct syntax to return the game properties.

Any help would be greatly appreciated.

Cheers

Comments

  • Invisible games are not listed, so you can't get it's properties at all.

    What you actually do with opGetGamePoperties() is ask the server for this room's properties. You shouldn't try that as the props are sent to you. Also, this operation will only work in a room (not in the lobby).

    Per RoomInfo object (room listed), you can access the properties that are sent to the lobby and "well known" (like isOpen).
    No need to fetch those values.
  • Thanks for your quick reply Tobias.

    If i'm "in the lobby", is a closed / invisible game still counted i.e PhotonPeer.getInstance().getGameList().length ? Or is this completely unseen?

    Could you help me with the AS3 syntax.
    I need a loop in the lobby to check all games, if there is an open/visible game then join it. Otherwise, create a new game.

    Sorry if this is basic stuff !

    Thanks again.
  • Invisible games are not in the list and as such, don't count.
    It turned out to be a bad idea to cycle through the list of rooms just to join one. With more traffic, more players will try to join the same room and thus, some will fail.

    It's better to use random matchmaking for this case and let the server pick a room.
    This is described here:
    http://doc.exitgames.com/photon-cloud/M ... references

    I hope this, the demos and the API reference will help.
  • Thanks Tobias, so the random matchmaking makes perfect sense.

    I have one more question. If I call opJoinRandomGame() when connecting to the lobby. How do I listen for a "fail" message if no games exist. At which point I will create the first game?

    Thanks again.
  • vadimvadim ✭✭✭
    You should listen to JoinRandomGameResponse event and check if event.hasErrors() == true.
    event.getReturnCode() returns an error code. ErrorCodes.NO_RANDOM_MATCH_FOUND means no room ready to play. You can send new room creation operation from this event handler.
Sign In or Register to comment.