Handling Room List Staleness
Photon Realtime does not provide a native client-side TTL (Time-to-Live) configuration for room list entries. The room list is managed by the server, and clients receive updates via the OnRoomListUpdate callback. Because the server pushes deltas rather than full snapshots, a client that has been idle or has missed updates may hold a stale local cache of available rooms.
Recommended Freshness Policy
For most matchmaking scenarios, a maximum staleness of 10 to 30 seconds is acceptable. In fast-paced environments, any room listed for longer than 30 seconds without a refresh is likely to result in a "Room Full" or "Room Not Found" error upon joining.
To balance reliability against bandwidth, developers should implement a hybrid validation strategy rather than a strict TTL purge:
- Soft TTL: Mark entries as "stale" after 30 seconds. Do not remove them from the UI, but trigger a manual
OpGetRoomList request if the user attempts to join a stale entry.
- Hard TTL: Remove entries from the local cache after 60–120 seconds if no server-side update has been received for that specific room.
Interaction with Lobby Update Intervals
The lobby's update interval determines how often the server pushes changes to the client. Adjusting this interval has a direct inverse relationship with the necessity of a client-side TTL:
- Short Update Intervals: Reduce the need for client-side TTLs and manual refreshes, but increase server bandwidth and CPU overhead.
- Long Update Intervals: Increase the likelihood of "ghost rooms" (rooms that are closed but still listed), making a client-side TTL essential to prevent a poor user experience.
Implementation Steps
- Timestamping: Store a local
DateTime timestamp whenever a room is added or updated via OnRoomListUpdate.
- Filtering: Before rendering the room list or allowing a join attempt, filter the local list for entries where
(CurrentTime - EntryTimestamp) < MaxStaleness.
- Verification: Use the
JoinRoom callback to handle failures gracefully. If a room is found to be stale/closed during the join attempt, trigger a full room list refresh to synchronize the cache.
Diagnostic Detail Needed: Are you using a custom Lobby implementation or the default Photon Cloud lobby? Custom lobby logic may require different synchronization triggers.