PUN Classic (also called PUN1) is the original and first major version of PUN. It is now replaced by PUN2 which is refactored and enhanced. We highly recommend starting new projects with PUN2 and if possible migrating existing ones from PUN1 to PUN2 by following our "Migration Notes". PUN Classic will be maintained for the coming months. We will fix important bugs and support new Unity versions but new features will be added only to PUN2.

Webhooks FAQ

How To Rejoin Rooms?

Actors can rejoin rooms before RoomOptions.PlayerTTL milliseconds of their deactivation time by calling OpReJoinRoom() from client SDK. Deactivation time is when an actor becomes inactive inside the room. An actor becomes inactive inside a room when it unexpectedly disconnects or leaves the room temporarily (without abandoning).

Back To Top

What If I Just Set EmptyRoomTtl To Its Maximum Value During New Room Creation?

This is not possible and the Photon Cloud will return an error indicating that EmptyRoomTtl should be modified to a lower value. The threshold of EmptyRoomTtl in Photon Cloud is set to 300,000 milliseconds (5 minutes) while this value could be changed for privately hosted Photon servers.

For realtime games, a best practice value of EmptyRoomTtl is 12 seconds (12,000 milliseconds).

Back To Top

Can Webhooks Modify The Room's State?

The short answer is no. However when you load a saved room state you can change few of its non binary top level properties.

Back To Top

Is There Any Interesting Use Case For Webhooks Other Than Storing And Retrieving The Room's State?

Well, there are many things possible with webhooks :)

Here's a list of few :

  • Server side authoritative code:
    This can be useful when some specific game logic need to be executed at server side only.
  • Protection against malicious hackers:
    Webhooks can also be handy when it comes to detect cheaters. PathProperties and PathEvent webhooks can be used to authorize players' actions from server side code.
  • Sending Push Notifications from server side:
    With PathEvent webhook sending push notifications can be optimized by sending it from server side to inactive players only.
  • Save game data other than Photon's room state:
    It is not an obligation to use only Photon's room properties or events cache as game data.
  • Analytics:
    Webhooks can be a powerful and free of charge analytics service. The statistics you can track are numerous like room creations, actors joins, room events, ...

Back To Top

Can Webhooks Modify Room Events Data Or Send New Photon Events?

No, webhooks cannot alter the data of received events nor send any other events.

Back To Top

Is It Possible To Access Custom Room Properties From Webhooks?

The short answer is no. However, the State object, available as an argument in "PathEvent", "PathProperties" and "PathClose" of Type=='Save' webhooks contains a readable form of public custom properties (i.e. visible to the lobby).

Back To Top

When Should An Actor Be Considered As Left Or Flagged As Inactive?

Any Photon actor disconnected from a GameServer has left a room somehow. The question is whether the same actor left the room intentionally - which means that he/she explicitly "abandoned" or "quit" or "exited" the room - or not. If left intentionally, the actor will no longer be part of the room's actors and thus removed from the room's ActorList. On the contrary, if the actor temporary left the room willing to rejoin it later then he/she will be marked as Inactive or IsActive = false or IsComingBack.

Any actor joined to a room and still connected to its respective GameServer will always be considered as Active. Actors status is exposed in the room's ActorList in the PathEvent webhook. See its respective section for more information.

To abandon a room, you should call OpLeave(false) and to leave it for a while just use Disconnect() or OpLeave(true). For possible scenarios like "resignation" or "rage quit" specific to some game types, the user could choose one of the two approaches.

See the PathLeave webhook section for additional information.

Back To Top

Does It Make Sense To Have 0 <= PlayerTTL <= EmptyRoomTTL With IsPersistent = True ?

PlayerTTL is the amount of time that an actor can stay inactive inside a room. Meaning, how long a player can stay disconnected from a room. If you create rooms with PlayerTTL = 0 then you should not expect players to come back. And if they don't come back then there is no need to save the room state for them. This is by design, a room state should be saved only if it contains at least one inactive player.

See the PathLeave webhook section for additional information.

To Document Top