nl.system.getInfo().gameService. In production it is wss://play.nodeloc.com/v1/ws. Connecting requires the game.realtime scope. js/net.js in the Dou Dizhu example is a complete client implementation (reconnection, resending, acknowledgments, heartbeat clock sync) that is not tied to any specific game, so you can reuse it directly.
Connect
- Get a game token with
nl.auth.getToken(). - After the connection opens, send
hello {token, build, device?, resume?: {roomId, lastSeq}}as the first frame. If it is not sent within 10 seconds, the token is invalid, thegame.realtimescope is missing, orbuilddoes not match the token, the server sendskickand disconnects. - Receive
welcome {serverTime, user}.user.idis the anonymous ID and matches theidin seats. - Send
ping {t}every 10 seconds; the server repliespong {t, serverTime}. The connection drops if no message is received for 45 seconds.
replaced).
Client → server
Server → client
Seat:
{seat, id, name, avatar?, ready, online, auto, bot?}. A seat with bot: true is a server bot, and the UI must label it. deadline is the deadline for the current move (Unix milliseconds).
Sequence numbers and reconnection
- The room sequence number
seqincreases monotonically, and each seat receivesroom.eventwith consecutive numbers. When you detect a gap, sendroom.snapshot. - When reconnecting, include
roomIdandlastSeqinhello.resume. The server resends the missing events, or sends a snapshot if too many are missing. - With multi-instance deployments you may receive
error {code: "room_moved", url}. Reconnect tourl.
Autoplay and bots
- If the player whose turn it is does not act before
deadline, the server performs the first legal action for them and marks them as on autoplay (auto). Making a move themselves or sendingroom.auto {on: false}cancels it. - If a quick match still is not full after waiting for a while, the server fills seats with bots and starts (not in friend rooms or ticket tables).
Fairness
The start event is{type: "start", data: {commit}}, where commit = hex(SHA-256(seed)). When the match ends, room.over.seed reveals the random seed. The client can verify SHA-256(seed) == commit and replay the deal from the seed.
Tables and settlement
The platform configures tables.kind is:
Call
nl.energy.confirmStake before sitting down at a stake table. room.over.settlement gives the actual game energy change for each seat:
error with code set to insufficient_balance, over_limit, stake_paused, or stake_failed.
Common error codes
unknown_type, bad_json, not_in_room, already_in_room, room_not_found, room_full, room_started, unknown_ruleset, unknown_table, forbidden, stake_unavailable, insufficient_balance, over_limit, stake_paused, draining, game_killed, rate_limited, room_moved, room_gone.