Photon Realtime and Application-Level Retries: Preventing Duplicate Event Execution
0 reputation · 27 Aug 2021, 01:58 UTC
Event Deduplication in Reliable UDP
Photon Realtime utilizes a reliable UDP layer to ensure packets are delivered in order. While the transport layer handles re-transmissions, application-level retry logic is often implemented to ensure critical state changes are acknowledged by the receiver.
A challenge arises when using RaiseEvent with reliable delivery. If a network interruption occurs after the receiver processes the event but before the sender receives the acknowledgment, a manual retry may result in the receiver executing the same game logic multiple times.
While Room Properties offer idempotent updates, RaiseEvent does not natively include a transaction ID to filter duplicate payloads at the OnEvent callback level.
Integration Constraints
- Requirement to maintain strict state consistency across clients.
- Avoidance of high-frequency Room Property updates to prevent network congestion.
- Reliance on reliable UDP for delivery without native application-layer deduplication.
What is the recommended pattern for implementing a lightweight deduplication mechanism within the OnEvent handler to prevent duplicate execution during manual retries? Should a sequence number be integrated into the event data payload, or is there a documented way to track event IDs across the network boundary?