onClientDisconnect

open fun onClientDisconnect(connection: Connection, reason: DisconnectReason)(source)

Called when a registered client connection stops being addressable - see DisconnectReason. Runs on the single-threaded dispatch executor (mcups-dispatch), not the caller's thread, so it must return promptly.

The default implementation does nothing; override to react (e.g. start a reconnect grace window on DisconnectReason.TIMEOUT, then keep the entities alive and rebind on a resume token).

Notify-only: DisconnectReason.TIMEOUT does not remove the registration or call Connection.terminate - the connection stays addressable by pushToAll until the application decides. A subsequent Connection.terminate then produces a second call here with DisconnectReason.TERMINATED.

Not called during stop; a full server shutdown is not a per-connection event.

Parameters

connection

the connection that stopped being addressable

reason

why