Urgent.News

What's breaking now, across thousands of outlets.

Tech

Lobby Host Succession Explained: 4 Rules After a Player Disconnect

The hard trade-off is speed versus truth: reassigning a lobby host on the first broken socket feels responsive, but it can create two hosts during a brief network interruption. Treat the socket as a signal, not as membership state. For a multiplayer-style shared workspace, keep an authoritative lease for each player, expire that lease after a bounded grace period, and choose the successor with a…

Node.js must carefully handle player disconnects in a multiplayer workspace to maintain a stable host and avoid confusion. A disconnected socket does not necessarily mean a player has left the workspace entirely. Players can reconnect using different connections, and processes may disappear unexpectedly.

To manage this, assign each successful connection a unique connection_generation number allocated by the server. Store a lease_expires_at timestamp and a stable joined_sequence number for each member.

When a player disconnects, use a heartbeat extension or delay to extend the matching connection_generation. If a player re-joins under a new connection_generation without a delay, treat it as a harmless no-op.

Set a grace period for handling disconnects based on your specific needs, rather than a fixed time limit. Longer periods improve membership retention during rough networks but increase handoff delays. Shorter periods reduce leaderless time but may misclassify brief gaps.

Four key invariants make the handoff process predictable: a member is online as long as their lease is valid for the latest connection generation; only one member can hold the host role for a given lobby revision; the successor is the eligible member with the lowest stable joined_sequence (with player ID as a tiebreaker); and each membership or host change increments the lobby_revision, with older revisions ignored.

In the case where the expired player is not the current host, remove or mark the member offline and increment the revision without changing leadership. If no eligible members remain, set the host to null. Keep presence transitions separate from authorization to maintain clear permissions.

Implement this logic in a single database transaction, ensuring a race condition between concurrent disconnects is avoided. Use an Express server to handle connection events, and a worker or timer to process expired leases. The repository should lock the lobby row, reject stale generations, choose an eligible member, and commit the new revision atomically.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Shared Elasticsearch clusters and the stream-claim flaw rated 8.8

Shared Elasticsearch clusters and the stream-claim flaw rated 8.8 Vulnerability overview CVE-2026-102406 is the highest-rated entry in Elastic's October 2026 advisory batch: CVSS v3 8.8, CWE-639, and…

  • Critical Elasticsearch vulnerability CVE-2026-102406 rated 8.8 in CVSS v3
  • Shared clusters and Kibana Fleet installer exploited via delegated package rights
  • 161,744 vulnerable Kibana deployments reported as of 2026-10-07

Capacitor Push Notifications for Lovable

Push is the feature that usually makes founders give up on the PWA route and wrap their Lovable app properly. A web app on iPhone only gets push after the user adds it to the home screen, and almost…

  • Capacitor push notifications simplify PWA push notifications on iOS and Android.
  • Detailed guide covers setup on iOS and Android, avoiding common pitfalls.
  • Paid Apple Developer account required for iOS silent push notifications.

Daily Pokémon Battle Game

I Built a Daily Pokémon Battle Game as a Browser-Based Strategy Puzzle I wanted to explore whether a turn-based battle could work as a small daily puzzle instead of an endless progression system.

  • Daily Pokémon battle game called Daily Red Pokémon
  • Players face same six-Pokémon team each day
  • Game operates without backend, hosted statically

More from Thursday 15 October →