Interface: Channel<T>
A named realtime channel carrying one JSON payload type.
Reliable messages preserve accepted per-recipient order and can be replayed
after an interruption or reload for up to five minutes after admission.
Retention normally uses service memory; planned updates preserve it, while an
unexpected service crash can lose events. Plot.connection.recovery reports known replay gaps.
Delivery can occur more than once around a browser interruption, so
duplicate-sensitive handlers need a stable action ID. latest samples may
be coalesced or dropped and are not a substitute for synchronized state.
If a send detects that Plot cannot safely retain a reliable message, it
throws a terminal internal-error synchronously. A hold deadline can instead
expire after a send has returned. Either failure stops this SDK instance;
later valid party or state reads, state writes, and channel sends report the
retained error. Reload or exit instead of retrying on the same page.
Type Parameters
T
T = unknown
Methods
broadcast()
broadcast(
payload):void
Sends a message to all eligible party players, including the sender.
Plot owns delivery and reconnect recovery. The method returns void; a
successful return is not a receipt that another player handled the message.
joining and left players do not receive it. A reliable message can be
retained for a temporarily disconnected player; a latest sample may be
dropped.
Parameters
payload
T
A supported JSON payload to send.
Returns
void
Throws
PlotNotReadyError when the complete ready state has not been installed.
Throws
PlotOperationError when Plot cannot safely retain a reliable message, or after the session, participation, or runtime has ended.
Throws
TypeError when payload is invalid.
See
sendTo()
sendTo(
playerId,payload):void
Sends a message to one party player.
Plot owns delivery and reconnect recovery. The method returns void; a
successful return is not a receipt that the recipient handled the message.
A temporarily disconnected player remains a valid reliable recipient;
joining and left players are not valid recipients.
Parameters
playerId
number
The stable ID of a connected or disconnected player.
payload
T
A supported JSON payload to send.
Returns
void
Throws
PlotNotReadyError when the complete ready state has not been installed.
Throws
PlotOperationError when Plot cannot safely retain a reliable message, or after the session, participation, or runtime has ended.
Throws
TypeError when payload is invalid, or playerId is out of
range, unknown, still joining, or belongs to a player who has left.
See
subscribe()
subscribe(
listener):Unsubscribe
Subscribes to messages received on this channel.
Channel messages are transient and are delivered to listeners active when
the SDK consumes them. Use Plot.gameState, or Plot.playerData for
genuinely player-specific data, when state must be readable by code that
subscribes later.
Register reliable listeners during startup, before Plot.ready(). This
does not start readiness. After readiness, a buffered reliable message may
invoke the listener synchronously before this method returns. Listener
errors are reported to the browser and do not stop other listeners. All
synchronous listeners for a delivery return before the next delivery runs.
Returned promises are not awaited: delivery does not confirm an asynchronous
state write. Store effects that must survive refresh in synchronized state.
Parameters
listener
(message) => void
Receives messages sent on this channel name.
Returns
An idempotent function that stops this subscription.
Throws
TypeError when listener is not a function.