[Feature] Netplay signaling for external emulators (UDP candidates & hole punching)

Open
#5,489 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python, redis

Research direction

Start by reading the existing netplay socket handlers and _is_room_peer guard, then inspect the netplay socket test suites named in the issue. The change spans room metadata, API listing, peer signaling, and coordinated punch timing; completion means those paths are covered by metadata round-trip, peer-only relay, punch broadcast, and non-peer rejection tests. The issue says this work depends on #5486 landing.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.

RomM's netplay rooms currently only serve EmulatorJS in the browser: peers exchange WebRTC offers/answers over the /netplay socket. External emulators (RetroArch and friends) do their netplay over plain UDP, so they can't use these rooms at all. Multiplayer between users of the same RomM server, each playing in their own emulator on desktop or mobile, currently has no home.

Describe the solution you'd like

Enable UDP + hole-punch multiplayer for external emulators between users of the same RomM server, with three small, backwards-compatible additions to the existing netplay socket:

  1. Optional room metadata on NetplayRoom (Redis JSON, no migration): transport ("webrtc" default, "udp" for external clients), client, core_id, rom_hash_prefix, protocol_version. Exposed in GET /api/netplay/list so guests can verify core/ROM compatibility before joining.
  2. A room-scoped udp-signal relay event carrying {kind, target, payload} (e.g. kind: "candidates" with LAN/STUN/UPnP address sets). Relayed only between verified members of the same room via the existing _is_room_peer guard, exactly like webrtc-signal today. The server never interprets payloads and never touches game traffic.
  3. Server-coordinated punch timing: on request, the server broadcasts udp-punch-start to both peers with a shared start_at_unix_ms timestamp so they can synchronize NAT hole punching. Game traffic flows peer-to-peer afterwards; no TURN, no relay bandwidth.
sequenceDiagram
    participant H as Host (launcher)
    participant S as RomM /netplay
    participant G as Guest (launcher)
    H->>S: open-room (rom_id, transport=udp, core_id, rom_hash_prefix)
    G->>S: join-room (preflight: core + ROM match)
    H->>S: udp-signal (candidates)
    S->>G: udp-signal (candidates)
    G->>S: udp-signal (candidates)
    S->>H: udp-signal (candidates)
    H->>S: request punch
    S->>H: udp-punch-start (shared timestamp)
    S->>G: udp-punch-start (shared timestamp)
    H->>G: direct UDP (NAT hole punch)
    G->>H: direct UDP (netplay session)

This is the signaling layer on top of #5486 (client-token auth on these namespaces): just enough for two external-emulator clients to find each other and establish a direct UDP connection.

Describe alternatives you've considered

  • Explicit per-purpose events (candidates, punch, handshake-result) instead of one generic udp-signal relay: more self-documenting, but more server code for the same relay role. Happy either way.
  • A separate namespace for external netplay instead of a transport field on the existing room: cleaner separation, but duplicates the room lifecycle that already exists and works.
  • An external matchmaking service (as some launchers host themselves): adds accounts and third-party infrastructure, and splits multiplayer away from the RomM server that already holds the users, the ROM permissions, and the room lifecycle. RomM-native signaling keeps everything in one place.
  • TURN relay fallback for peers behind symmetric NAT: useful, but out of scope here. Direct P2P covers most pairs; relay support can follow if needed.
  • Handshake telemetry (RTT/jitter reporting) and a server-wide "joinable sessions" endpoint (like streaming's): both nice to have, both better as follow-ups than as part of this change.

Additional context

  • EmulatorJS rooms and the webrtc-signal path are untouched; new fields are optional and default to current behavior.
  • Token-authenticated clients act within their token scopes (#5486); anonymous password-guest behavior is unchanged.
  • No DB migrations, no new dependencies, no TURN/relay infrastructure, no frontend changes required.
  • Tests would extend the existing netplay socket suites: metadata round-trip, peer-only relay, punch broadcast, and rejection of signaling to non-peers.

Happy to implement this against current master once #5486 lands, with the same test coverage style.

Dominant language
Python
Stars
13.3k
Forks
747
Avg merge
20h 58m
Merged PRs (30d)
207

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rommapp/romm

All issues in rommapp/romm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.