Room Properties update too slow for lobby.

Hi, I am using the Photon Realtime C# SDK for Unity with LoadBalancing. I am making an asynchronous turn-based game, and players take turns asynchronously, and each turn I set new custom room properties using
OpSetCustomPropertiesOfRoom(boardProps, null, . . .) (based off Memory demo).


The properties are properly initialized using CustomRoomPropertiesForLobby = ... when the room is created. My problem is sometimes it takes very long for the new room properties to be seen in the lobby.

For example, if a new room is created and the first turn is played and the client returns to lobby, the client, connected to master will call OpWebRpc("GetGameList", null); and the room will immediately show up, but the OnWebRpcResponse(WebRpcResponse response) will have null in the response.Parameters KeyValuePair "Properties" key for the new room. Sometimes it will take up to 5 minutes for the "Properties" to be populated with the data by the server.


Is there any way I can get those properties to update faster? I am trying to make a modern lobby where a player can see which games are "Your Turn" or "Their Turn" or "You Won", like in Words With Friends or any game like that. 5 minutes is way too long for a response. Here is a little visual example of what I'm going for:



Just in case you want them, here are my roomProperties in full:
RoomOptions roomOptions = new RoomOptions() { MaxPlayers = 2, CustomRoomPropertiesForLobby = new string[] { PropTurn, PropNames, PropIds, "wn" }, PlayerTtl = int.MaxValue, EmptyRoomTtl = 300000, CheckUserOnJoin = true, CleanupCacheOnLeave = false }; and we use LobbyType.AsyncRandomLobby


Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2017
    Hi @lorddanzig,

    Thank you for choosing Photon!

    It seems like there is a confusion here.
    • 'GetGameList' is a WebRPC that is not built-in in Photon. Read more about it here.
    • 'AsyncRandomLobby' is a type of lobby that does not periodically propagate rooms lists.
    To achieve what you want in Photon you need to have a web service that implements Webhooks or WebRPCs (e.g. 'GetGameList').
    Read more about how to make "Turn-based or async. games in Photon".
  • lorddanzig
    edited September 2017
    Hey thank you for the response, I guess I didn't explain my setup well in my post. I included info about my lobby just in case it was contributing to my problem. I'm using a webservice (Heroku) and webhooks is implemented fine.

    My issue stems from the OpSetCustomPropertiesOfRoom() method. The custom properties of the room are not visible for a long time (from players outside of the room) after they have been updated. Sometimes 3 minutes, sometimes up to 5 minutes. Joining the room will give players the most up to date events and properties. But my players outside of the room have to wait a long time to see the latest properties. I don't think its a problem with my webservice because I noticed the same behavior using Heroku or Webscript.io.

    The gameplay is working fine and everything is finished on that end, I would just like to make these properties update faster to players who are outside of the room


  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2017
    OK I see.

    The default "GetGameList" WebRPC returns only lobby properties (room properties visible to the lobby).
    The room state exposed by Photon includes only a "read only" lobby properties.
    All room properties are either on their binary form or inside the debug info.

    I think you are already know that but maybe you are not saving the room state or room properties only until a room has been 'closed' once, i.e. in 'GameClose', Type="Save". So you should save an initial version of the room properties in 'GameCreate' and update that copy in 'GameProperties' every time.
    In 'GetGameList' you should be able to return room properties even before the room is not closed yet (still alive).
    Also 'EmptyRoomTTL' is probably why sometimes you wait for up to 5 minutes.
    You can set it to 0.
  • lorddanzig
    edited September 2017
    Thanks JohnTube, but I'm not sure I understand. I have a weak understanding of the WebRPCs, but I am using the turnkey solutions for the WebRPC from here and I believe the state is properly initialized in GameCreate.

    Additionally, when I call OpSetCustomPropertiesOfRoom() I am expecting a WebRPC to be automatically fired by Photon, because at this link it says:

    GameProperties

    This webhook is fired every time the user sets the custom properties of either the room or the player from the client side if the right overload method is used with the HttpForward web flag set. The Type argument sent with the webhook will be set accordingly to Game or Actor.


    So I assume that by calling OpSetCustomPropertiesOfRoom with the proper arguments, photon will call the "GameProperties" webhook with the "State" variable properly set. Do I need to call an OpWebRPC() to force the state to update as well? I could do OpWebRPC("GameProperties", ???) but I think this is done automatically by Photon and I am not sure what to pass as an argument (a serialized version of the room's state perhaps, but I am not sure the correct formatting for this).

    My custom properties are currently being set, it just takes a long time for them to show up to players outside the room.

    EDIT: I tried setting EmptyRoomTTL to 0 and nobody can join the game once the first player leaves (set inactive). I am investigating my code to see if I am closing the room someplace.. I dont think I am though. The flow is like this: Player1-> Creates room -> Plays Turn -> Leave room (inactive) ... now another Player2->random matchmaking-> no room found
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2017
    As you can see here in 'GameCreate.py' we save an empty room state when the room is first created.
    So a player who just left the the room will not be able to see any room property until the room state is saved when the room is closed after 'EmptyRoomTTL' (this is why you get 'null' room properties for some rooms in 'GetGameList' response).

    So I think that line should be replaced with:
    db.set_game_state(jsonRequest['GameId'], json.dumps({'CustomProperties': jsonRequest['CreateOptions']['CustomProperties']}))
    I need to test this myself.

    Do I need to call an OpWebRPC() to force the state to update as well?
    No you do not need to. If you are using Webhooks 1.2 you need to set HttpForward webflag in OpSetCustomRoomProperties to trigger the 'GameProperties' callback.

    I tried setting EmptyRoomTTL to 0 and nobody can join the game once the first player leaves (set inactive)
    If you use webhooks 1.2 set AsyncJoin to true. Read more about it here.
  • JohnTube
    JohnTube ✭✭✭✭✭
    @lorddanzig I have updated the github repo for the heroku app.
    test it now and let me know.
  • lorddanzig
    edited September 2017
    Edit: The problem is fixed!
    I had to set the EmptyRoomTtl = 1 ms, EmptyRoomTtl =0 was not causing the GameClose to fire for a few minutes. EmptyRoomTtl =1 causes GameClose to fire immediately when all players go inactive. Not sure why :)

    Thanks for your help JohnTube!

    And in case anyone else had this problem, make sure your Lobby has a name, like this OpCreateRoom(newRoomName, roomOptions, new TypedLobby("Lobby" ,LobbyType.AsyncRandomLobby),null);, if you leave the name as null you will use default lobby type no matter what.

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2017
    Update:
    I just read your updated comment.
    Great then! I'm glad you managed to make it work finally.
    Not sure about the 'EmptyRoomTtl = 0' though.

    ---

    Hi @lorddanzig,

    It seems we need to investigate issues with 'AsyncRandomLobby'.

    Meanwhile you can set 'EmptyRoomTtl' back to max value of 5 minutes to allow empty rooms to be matched for 5 minutes.