GameClose, Type: "Save" web hook

Hi,

I originally posted this question to unity forum and redirected to here by tobiass.

We are trying to use GameClose, Type: "Save" web hook.

We are using custom room properties heavily during gameplay and we need to persist in game close hook.

In our tests we see that custom room properties do not exist in under CustomProperties tag in received from photon web call. Instead custom room properties are under debuginfo tag in json.

How can we save custom room properties GameClose, Type: "Save" web hook and load them later ?

Additionally, how can I set EmptyRoomTTL to 300000 and PlayerTTL to 0 in PUN Free ? There is no EmptyRoomTTL parameter in RoomOptions class as far as I can see.

Thanks.

... and tobiass said(for contextual purpose):
I will have to forward the questions about WebHooks and the content of the "save" hook to my colleagues. Those are best discussed in a dedicated thread in our forum.

About PlayerTTL and EmptyRoomTTL: In PUN you can only set one to simplify matters. PUN is not fully compatible with persisted games (using PhotonViews and ownership is a bit tricky, when you return to the room). But it seems you rely mostly on props.
If you would set PlayerTTL to 0, any player who loses connection will be timed out and can't simply return to the room.
Let me guess, you try to create a persistent world with as many/few players as happen to be there?

Please post more details of what you want to achieve in our forum. A discussion of this is too complex for this super long thread. http://forum.photonengine.com

Comments

  • protoshape
    edited August 2016
    Let me elaborate our case:

    A part of our Unity game is turn based P2P battle. If players left the room more than 5 minutes we need to persist & retrieve all game state including custom room properties in GameClose, Type: "Save" web hook. Every unit movement and action stored in custom room properties in the game logic. So we can easily retrieve the state and join the game very easily. We do not want to use game properties web hook for every property update. Because this is useless and costy in our case.

    Second part of the question, if a player left the room intentionally or unintentionally other player should receive player disconnect event. So, other player can switch to AI to resume the game session instantly without any break. As far as I understand to achieve such a thing we need to set room properties PlayerTTL = 0 and EmptyRoomTTL = 300000. Right ? This is a critical thing for us, if PUN or PUN+ does not support such a thing, could you please help us to support this in PUN ?

    Thanks.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @protoshape,

    we need to persist & retrieve all game state including custom room properties in GameClose, Type: "Save" web hook


    Room and actor properties as well as cached events and room options are included in the room state. I don't understand the issue here if all you need is to save and load state. Maybe you missed how loading state works; you just need to return the saved "State" in GameCreate webhook.

    Unless what you want is to access custom room properties outside "State" or in deserialized form or when room is "destroyed", then here is what you need to know:

    Currently, custom room properties cannot be accessed from web service in their deserialized state only in two cases:
    - "State" includes "CustomProperties" that contains properties that are visible to the lobby.
    - In "PropertiesChanged" webhook.

    Since you ruled out second option, you can consider making properties visible to the lobby which might not be very convenient.

    We are discussing better ways of exposing room state in webhooks in the future. Your suggestions are welcome.

    About "EmptyRoomTTL" in PUN:
    after reading your 2nd post I'm more confused, do you want room state persistence or not?
    if so, then you should not set "PlayerTTL" to 0, you probably want to set it to -1. Do not worry much about "EmptyRoomTTL". I invite you to read our "Room Persistence Guide".
  • JohnTube
    JohnTube ✭✭✭✭✭
    Update:

    After discussing this with my colleague @Tobias
    we can help you with a workaround:

    please set "EmptyRoomTTL" value in line 139 of "LoadBalancingPeer.cs" inside method LoadBalancingPeer.RoomOptionsToOpParameters.

    Sorry for the inconvenience.
  • Disclaimer: I didn't read all of the conversation. I will have to catch up, if I'm missing something. Let me know, I will follow this topic (continued on Monday)...

    Second part of the question, if a player left the room intentionally or unintentionally other player should receive player disconnect event. So, other player can switch to AI to resume the game session instantly without any break. As far as I understand to achieve such a thing we need to set room properties PlayerTTL = 0 and EmptyRoomTTL = 300000. Right ? This is a critical thing for us, if PUN or PUN+ does not support such a thing, could you please help us to support this in PUN ?


    To persist games, you can set the "isPersistent" value on the Dashboard. Once done, the client can control how long a player may be inactive in the room before being "kicked" and the clients control how long the room stays in (server) memory, before the state gets saved on your web service (via WebHooks).
    When a room (or bestter: an application) is persisten, players might become "inactive" in a room. They are not connected but part of the game and they might re-join the game. This additional state is used when any client disconnects or times out. In persistent games, you deliberately have to "abandon" a game to leave it right away.
    Please note: If a player leaves the room and becomes inactive, the remaining players get an event updating their local view of that player.

    PUN does not yet have a way to abandon a persistent room.
    Currently, PUN does not fully support persistent rooms, because we don't have a way to store the last position of a networked game object, when the controlling player leaves a room (and doesn't abandon it).

    So, depending on your needs, PUN is not the best solution for you. That said: As you already just use properties, you should be fine. I just want to give you the background info why some things are as they are now.

    We can easily add the option to "abandon" a persistent room and Hamza already described how to work around the EmptyRoomTTL / PlayerTTL "link".
  • Hi JohnTube & Tobias,

    It worked :) I added EmptyRoomTTL parameter to LoadBalancingPeer.cs. PlayerTTL=0 AND EmptyRoomTTL=300000 is working now. However, I believe that ability to set this parameter in standard API would be so nice.

    We wrote our web services for web hook, and by just taking/giving state information from photon, persistence is working this way, including custom room & player properties. Just one more question, coming of all lobby invisible parameters in debug info tag is disturbing me because later in production phase i afraid that they can be removed for any reason ? Can we trust this result for production ?

    I believe that state information custom properties tag in GameClose event web hook state should include both lobby visible/unvisible room properties. If it can be in debug info, it can also be in custom properties very easily logically.

    Thank you so much.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited August 2016
    Hi @protoshape,

    I think you mixed the values. In order for persistence to be enabled you need to have PlayerTTL != 0. So it can't be 0.

    We do not recommend relying on "DebugInfo" property to get custom properties.

    Please take a look at other discussions (this one for instance, and I invite you to take a look at @onealexleft questions in other discussions also) on the forum regarding what should the room state expose to webhooks. For the time being you should use a workaround or adapt your design to what webhooks can offer.