Change commands and retries
How does the game server recognize duplicate and changed input?
Scale alone does not ensure consistent retry behaviour. This proposed API binds the role, business object, change payload and expected state to each new intent. An idempotency key identifies the same intent after a response is lost.
Starting point Measure per-session capacity and concurrent session count separately.
Assumptions for the example case
A fictional example design: one session with at most 32 players, server-authoritative movement, one-time pickup of world items, reconnection within the same session and durably confirmed rewards. Figures and quality goals are illustrative test assumptions. A shared global game world, player trading, paid items and comprehensive fraud detection are outside the scope.
Retries and new intent
Input envelope · Generation and sequence are part of the contract
The same sequence returns the same record; altered content conflicts, and old generations lose authority.
Proposed domain API contracts
- POST
/sessions/{id}/joinAssign an authorised player character to a session.
- Input
- Authentication-service evidence, W-21, player identity and stable join key.
- Result
- Session assignment, current authority generation, and input start sequence; full or completed session is rejected.
- Retry behaviour
- An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
- POST
/sessions/{id}/inputsAccept a pickup as an authoritative game command.
- Input
- W-21, player P-21, current generation, input sequence, requested tick and item G-21. Position comes from server state rather than the client.
- Result
- Ordered input; a valid pickup at most 2000 mm away creates exactly one durable winning record before the final response. An already allocated item, old generation or invalid distance produces an explicit conflict.
- Retry behaviour
- An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
- GET
/sessions/{id}/stateRead confirmed world state and ownership.
- Input
- Authorised player, W-21, last known generation and tick.
- Result
- Current generation, state snapshot and durable winning record; replaceable movement and confirmed ownership remain distinguishable.
- Retry behaviour
- Repeating a read creates no business effect; the returned current state may change between requests.
Bind the sequence to the session
Validate input sequence numbers within the player and session identity.
A client resends a pickup command after the response is lost.
A duplicate pickup returns the same record; altered payload is explicitly rejected.
- Alternative considered
- Timestamps alone are ambiguous when clocks differ.
- Trade-off
- Client and server maintain sequence state.
- Reassess
- Very long sessions require a defined sequence rollover procedure.
Terms in this step
- Bind the sequence to the session
- A duplicate pickup returns the same record; altered payload is explicitly rejected.
Try it yourself
Send the same input sequence once for G-21, then unchanged and then with a different object. Predict the answers.
A hint for your attempt
Use the specific entities and conditions from this step. The two solution parts distinguish the decision from its evidenced outcome.
Compare with a possible solution
- First part of the solution
- An identical retry returns the same winning or conflict record without another award.
- Second part of the solution
- A different item under the same sequence is a protocol conflict. A new legitimate attempt needs a new input sequence.
Apply to your project
Which corresponding assumption would you test first in your project? Consider this trigger: Very long sessions require a defined sequence rollover procedure.