Class PlayerLinkChannel

java.lang.Object
com.ultikits.ultitools.utils.PlayerLinkChannel
All Implemented Interfaces:
CloudPlayerLinks.Transport

final class PlayerLinkChannel extends Object implements CloudPlayerLinks.Transport
Carries the player-link protocol behind CloudPlayerLinks: it frames player.link.create, correlates the answer by envelope id, delivers completions and expiries to the single owning module, and records each completion result in the shared ledger before answering the gateway.

Pending creates are keyed by the envelope id the channel reports for the frame it just sent. A completion whose create is still pending without an answer waits for that answer so the module sees the link before the completion; a completion that arrives after a restart, with no create pending in this run, is delivered straight away.

Order of a completion result: the result is recorded and persisted in the ledger under the completion's envelope id before the player.link.completed.result frame is handed to the socket. A redelivery of that id finds the recorded result and re-sends it without calling the handler again. A handler that does not answer in time sends nothing, so the gateway redelivers.

The result of a handler call is sent on the connection that is live when the handler finishes, not on the one the completion arrived on: the module may work for seconds, long enough for the socket to be replaced. If no connection is open at that moment, nothing is sent and the persisted receipt answers the next redelivery.