mp.realtime + RealtimeClientawait mp.realtime.get(playerToken)
Mints the realtime credential for the player's current realtime-enabled room — one live token per player, ~5-minute connect window. Returns token + realtime_server coordinates.
const rt = mp.createRealtime(opts); await rt.connect(token, realtimeServer)
Opens the WebSocket control lane (wss://, client=json). Resolves on the server's connected envelope — exposes connectionId, playerInfo, udpEnabled.
rt.send(target, command, data, { targetIds?, seq? })
Reliable ordered message — targets 'all' | 'host' | 'others' | 'specific'. Host ACL is enforced server-side: non-hosts may only target 'host'.
await rt.connectUdp()
Binds the MUR1 UDP fast lane via node:dgram — datagrams authenticate through the WS-issued connection id. Node-only; rejects with ConfigurationError in browsers.
rt.sendUnreliable(target, command, data, { targetIds?, seq? })
UDP when bound, automatic WebSocket fallback otherwise — browsers get WS delivery since they physically cannot send UDP.
rt.heartbeat()
rt.close()
Keepalive (auto-scheduled every 20s vs the 60s idle close) and clean shutdown — closes UDP socket and WS.
onConnected · onReceive · onSent · onError · onClose
Assign handlers via options or properties: onReceive(command, data, sender, seq) fires per peer message.