Introducing a new way to review your PRs.

Read the announcement

rommapp / romm

A beautiful, powerful, self-hosted ROM manager and player.

View on GitHub

22 documents · Updated Nov 23, 2026

docs / netplay-and-streaming

Netplay and streaming

Netplay and streaming provide two ways to start a shared or remote play experience. Netplay keeps the game in the browser and coordinates players through a realtime room. Streaming runs the game in a separate emulator container and returns its video to the browser. Both paths connect play launch with session ownership, safe cleanup, and play-history recording. Streaming also keeps game saves and save states in the library so a session can move between containers.

Netplay

Netplay lets EmulatorJS players meet in a room for the same game. RomM supplies room discovery and a realtime relay, while EmulatorJS manages the game-side peer connection and input exchange.

Room discovery

Room discovery is a read-only API that shows rooms which can still accept a player for the requested game. The endpoint uses the same not-found result for a missing or hidden game, then hides full rooms and rooms for other games. It exposes only the data needed to choose a room.

InterfacePurpose
GET /api/netplay/list?game_id=<id>Return open rooms for one game
Room resultProvide the room name, current and maximum player count, owner name, and password presence

The EmulatorJS player calls this endpoint when its game starts. It also supplies the signed-in user's name to the netplay UI when no player name is already set. This keeps the room view tied to the RomM account without changing EmulatorJS's room model.

References: frontend/…/Player.vue• L388-416 backend/…/netplay.py• L55-77

Room lifecycle

A netplay room is a short-lived shared record keyed by the EmulatorJS session ID. The first socket creates the room and becomes its owner. Other sockets can join only when the room exists, the password matches, the game matches, and the player limit has not been reached.

When a player leaves, RomM removes that player and publishes the new member list. An empty room is deleted at once. If the owner leaves while players remain, another connected player becomes the owner. A scheduled cleanup runs every 30 minutes and removes empty records that remain after an unexpected disconnect.

flowchart TD
    A[EmulatorJS opens netplay socket] --> B{Room exists?}
    B -- No --> C[Create room and assign owner]
    B -- Yes --> D{Password, game, and capacity valid?}
    D -- No --> E[Reject join]
    D -- Yes --> F[Add player to room]
    C --> G[Publish member list]
    F --> G
    G --> H[Players exchange game data]
    H --> I{Leave or disconnect}
    I --> J[Remove player]
    J --> K{Room empty?}
    K -- Yes --> L[Delete room]
    K -- No --> M[Publish member list and reassign owner if needed]
    L --> N[Periodic cleanup removes any empty leftovers]

The room record lives in Redis so all backend workers see the same membership state. Socket session data links each connection to its room and player ID. This lets an explicit leave and a lost connection use the same cleanup path.

References: backend/…/netplay_handler.py• L7-50 backend/…/netplay.py• L24-150 backend/…/cleanup_netplay.py• L6-29

Realtime interaction

The netplay socket is a separate Socket.IO application mounted at /netplay. It uses Redis as its shared client manager, so room events can reach players connected to different backend workers.

The socket relays WebRTC signaling messages to a named peer. Signaling means the offer, answer, and network-candidate messages that help two players establish their media or data path. After the peer path is ready, room-scoped data-message, snapshot, and input events are broadcast to the other players. The relay does not define the game protocol. EmulatorJS remains responsible for interpreting those messages.

Event groupDirectionRole
open-room, join-roomClient to serverCreate or enter a room
users-updatedServer to roomPublish current members
leave-room, disconnectClient or socket to serverRemove a player
webrtc-signalClient through server to peerCarry peer setup messages
data-message, snapshot, inputClient through server to roomRelay game coordination data

The browser points EmulatorJS at the current origin for netplay and passes configured ICE servers when netplay is enabled. ICE servers are connection helpers used when players cannot connect directly. RomM also patches the bundled Socket.IO client to use /netplay/socket.io, which keeps netplay traffic on the mounted realtime service.

References: frontend/…/Player.vue• L176-188 frontend/…/Player.vue• L418-428 backend/…/netplay.py• L152-224 backend/…/socket_handler.py• L7-26

Streaming

Streaming provides a native emulator as a browser-facing service. RomM resolves a configured container for the ROM's platform, claims that container for one user, prepares the user's persistent data, starts the game through a server-side broker, and displays the broker's WebRTC page in the player.

Streaming configuration

Streaming configuration turns container settings into the choices used by the player and the backend. It separates the browser host from the broker address, assigns an emulator namespace for stored data, and resolves the capabilities that control which actions the player can offer.

Configuration conceptSystem role
Enabled flagTurns streaming availability on or off
Platform mappingSelects one emulator container or an interchangeable pool for a ROM platform
Browser hostGives the iframe its WebRTC page; this can be an absolute URL or a same-origin reverse-proxy path
Broker addressGives the backend its server-to-server control address
Emulator namespaceKeeps states, save archives, and memory cards tied to the emulator that can read them
Broker protocolSelects the route shape and features of a webstation or legacy broker
CapabilitiesDefines state slots, autosave behavior, disc swap, memory-card support, save picking, and live controls
Transfer limitsBounds the size and time of state and save transfers

The broker boundary supports webstation containers and older per-emulator brokers. Webstation can expose shared rooms, desktop sessions, launch progress, disc changes, and declared save or state imports. Older brokers expose fewer actions. The resolved capability set keeps the player from offering an action that the selected broker cannot honor.

Each resolved container has one stable claim identity derived from its broker address. A container that serves more than one platform still has platform-specific records so saves, cards, and core choices are resolved for the claimed platform. Containers form a pool only when their emulator namespace, memory-card mode, save-picker behavior, core choice, broker protocol, and experimental-core policy match.

Configuration separates the host that a browser can open from the broker address that the backend can call. Visibility checks run before configuration is returned. The streaming permission controls who can see the service and start a session. Starting a session needs both read and write access to the caller's own streaming sessions, while joining another user's session needs read access. The user-write scope is also required for session changes, which prevents shared kiosk identities from changing another user's session. Platform and ROM visibility checks apply to configuration, claims, session details, and joins. For RetroArch, state choices follow the core that the broker can run, so the player does not offer states that the active core cannot load.

Known cardless platforms do not use whole-card sync even when a container enables that setting. This keeps platforms whose saves live in their own disk or NAND data on their normal save-file path.

References: backend/…/access.py• L54-87 backend/…/access.py• L129-155 backend/…/capabilities.py• L188-267 backend/…/config.py• L160-234 backend/…/config.py• L278-449 backend/…/config.py• L762-839 backend/…/streaming.py• L342-392 backend/…/streaming.py• L401-439

Streaming launch

Streaming launch is a claim-before-start flow. The player sends a ROM ID and optional resume state, save archive, memory card, card-import answer, disc choice, and shared-play choice. The backend checks the caller's streaming permissions, ROM visibility, and selected assets before it reserves a compatible container.

ROM lookup and visibility use one not-found path before platform containers or resume data are exposed. This keeps a missing or hidden ROM from producing a different launch surface than an inaccessible ROM.

The claim is reserved before the slow broker work starts. The API returns 202 after synchronous preparation, then a detached launch keeps the claim alive while the broker starts the game and extracts large titles.

sequenceDiagram
    participant U as Player
    participant R as RomM API
    participant C as Redis claim
    participant B as Emulator broker
    participant E as Container web UI

    U->>R: POST /api/streaming/sessions {rom_id, play choices}
    R->>R: Check permission, ROM visibility, assets, platform, and capabilities
    R->>C: Claim a compatible container
    alt Claim fails
        C-->>R: Container or platform is busy
        R-->>U: 409 busy
    else Claim succeeds
        R->>R: Prepare card, save archive, and resume state
        R-->>U: 202 reserved and launching
        R->>B: Launch the ROM from a server-derived library path
        B-->>U: streaming:launch-phase while launch is in progress
        alt Broker launch fails
            B-->>R: Error or no response
            R->>C: Abort the claim
            R-->>U: streaming:launch-failed
        else Broker launch succeeds
            B-->>R: Launch-ready result
            R-->>U: streaming:launch-ready with host
            U->>E: Open the host in the player iframe
        end
    end

The claim is atomic per broker identity. A second claim from the same user and platform is also gated. An abandoned claim can be taken over only after its heartbeat becomes stale. A drain marker is not taken over because it means that the old emulator or an exit transfer is still finishing.

Persistent data has separate paths. Save states are central library assets that can resume a chosen point or hydrate the newest state after launch. In-game saves are emulator-native data that must reach the container before boot and return to the library after exit. Whole memory cards use a protected sync path. On first use, the player may adopt or discard a card already held by the container, and that answer is kept for the container.

Streaming launch reports progress and readiness through realtime events. streaming:launch-phase reports broker extraction progress when supported. streaming:launch-ready provides the browser host after the game starts. streaming:launch-failed reports a useful refusal or failure and releases the claim. The status endpoint provides recovery when a tab misses an event.

The player keeps the container and claim timestamp from the 202 response. It accepts launch messages only when both values match. The launch page refreshes configuration before it offers resume choices, and the backend supplies state IDs that are safe for the selected broker and core. An explicit save choice is sent to the claim. Otherwise the backend can choose its newest compatible save.

Foreign saves and states use one import archive when the broker declares support for them. RomM filters unsafe names and applies member-count, expanded-size, and manifest-size limits before upload. The archive records the origin and type of each carried member. If a selected foreign item cannot be carried, the launch reports the broker's refusal or falls back to the newest native save when that is safe.

The exit archive can contain a delta from the save restored at launch. RomM keeps the restored save identity and content hash with the session, then overlays the exit delta only when that base is still the same library asset. This prevents a later library edit from being merged into the wrong session result.

The two broker shapes use different route and response rules. Webstation accepts a declared import archive and can report why a save or state member was refused. Legacy brokers use their older per-emulator routes and expose fewer launch controls. RomM keeps the launch contract common while translating these broker differences at the boundary.

RomM sends a ROM language hint and a user-interface language fallback when the broker supports them. Known language names and locales reduce to broker-readable codes. Unknown values are omitted so they do not block a launch.

References: backend/…/streaming.py• L401-439 backend/…/streaming.py• L835-1147 backend/…/launch.py• L44-217 backend/…/launch.py• L265-318 backend/…/access.py• L75-79 backend/…/archive.py• L10-132 backend/…/broker.py• L93-170 backend/…/imports.py• L46-185 backend/…/states.py• L125-176 backend/…/saves.py• L467-499

Streaming controls

The active stream page is a player shell around the container web UI. It uses local browser messages for same-origin audio when possible and authenticated backend routes for broker control and cross-origin streams. Mutating routes resolve the claimed container, check the claim owner or an administrator, and refresh its liveness.

ControlEffect
Volume and muteChange local viewer audio for same-origin streams or broker audio for cross-origin streams
Save stateCapture the supported slot and add the result to central state history without stopping play
Load stateLoad the supported slot
FullscreenExpand or leave the player shell
StopEnd the session without requesting a new state capture
Save and exitSave, stop the emulator, collect exit data, and release the session
Disc swapChange the mounted disc when the platform and container support it

The backend sends capabilities with the streaming configuration. The player hides unsupported actions and blocks conflicting state operations while one is active. State captures sync to central history in the background. A capture keeps its own history entry and may include a screenshot for the resume picker. RetroArch history is filtered by the active core so a state from another core is not offered or loaded.

A joining viewer can watch the host's room and control local audio, but cannot save, load, change shared volume, or release the host's claim. The join route does not apply the host's resume state, save archive, memory card, or multiplayer launch choices. The player protects the session from accidental navigation. Browser back, route changes, reload, and the gamepad exit chord open a confirmation dialog. A joiner leaves the room without affecting the host.

The player matches realtime messages to both the claimed container and the claim timestamp. A socket push gives fast feedback. A status poll and a visibility recheck recover a tab that missed the push or slept in the background. A claimed container stays available to the running page if permission or configuration data changes during play. A joiner does not poll or heartbeat the host's claim.

References: backend/…/streaming.py• L1274-1589 backend/…/states.py• L590-824 backend/…/access.py• L45-79 backend/…/capabilities.py• L188-219 frontend/…/Stream.vue• L547-866 frontend/…/Stream.vue• L879-1268

Streaming cleanup

Cleanup must end both parts of a streaming session: the Redis claim and the running emulator. Owner release, administrator release, and stale-session takeover use the same protected lifecycle so persistent data is collected before another player can use the container.

When teardown starts, RomM reserves the claim with a guarded drain marker or a held claim. It stops the emulator first. It then evacuates and wipes a synced memory card while the container is still protected. It records play activity, collects exit state, starts the save-archive pull, and releases the claim when protected work can no longer affect the container. A failed step does not leave a phantom claim.

Cleanup follows one order for normal release, save-and-exit, administrative release, and stale-session takeover.

flowchart LR
    A[Player, admin, or stale-session takeover] --> B[Reserve claim for teardown]
    B --> C[Stop emulator]
    C --> D[Evacuate and wipe synced card]
    D --> E[Record play activity]
    E --> F[Collect exit state and save archive]
    F --> G[Release claim or hold drain marker]
    G --> H[Container available again]

Normal release can return before detached teardown finishes. Save-and-exit waits when card sync needs a quiet card or when the player requests a confirmed result. If the broker continues stopping in the background, a short drain marker blocks a new launch. If an exit state is still being collected, the marker is refreshed until that work ends or its safety ceiling is reached. A pending save-archive pull also makes the next claim for that user's ROM wait for the archive to be filed, but the wait has a bounded budget so a broken broker cannot block play forever.

Session records use guarded compare-and-set updates. A late heartbeat, disc swap, launch completion, or release therefore cannot write an old claim over a newer one. Long-lived claims stay alive through heartbeats and successful controls. A stale heartbeat allows the next suitable claim to run the same cleanup. A failed cleanup still releases its own claim in a final path so a phantom reservation cannot block the container forever.

Broker calls use the server-side broker address and bounded time and size limits. Non-critical state and save pulls are best effort. Whole-card hydration and teardown remain protected because they decide whether the next player can safely use the container. Webstation exit archives are pulled from the export list by broker session ID and removed after RomM receives them. Browser pagehide uses keepalive requests so a closing tab can still ask the backend to save and stop or release.

Force release records a termination notice and sends streaming:session-ended when possible. The status endpoint is the fallback when the socket event is lost. The frontend keeps its local claim until a release succeeds, so it can retry instead of treating a still-held container as free.

References: backend/…/streaming.py• L1150-1336 backend/…/streaming.py• L1592-1638 backend/…/streaming.py• L1869-1941 backend/…/archive.py• L15-37 backend/…/broker.py• L123-221 backend/…/lifecycle.py• L48-265 backend/…/lifecycle.py• L399-563 backend/…/saves.py• L41-143 backend/…/session_store.py• L226-284 backend/…/session_store.py• L371-567 frontend/…/Stream.vue• L762-866 frontend/…/Stream.vue• L1342-1442

Shared streaming sessions

Shared streaming lets a host publish an active container session for other users to join. The host opts in at launch. RomM lists only visible sessions and asks the broker for a room URL when a joiner arrives. The host keeps ownership of the emulator and its persistent data.

The join path is read-only for the joining user. It does not create a second emulator claim because the joiner views the host's existing broker room. RomM checks that the caller has join permission, the host opted in, the broker supports joining, and the host's ROM is visible to the joiner. RomM checks these rules in both listing and join so a stale listing cannot grant access. If the host closes the session between listing and joining, the request reports that the room is no longer available and the player removes the stale entry.

The list and join routes apply the same visibility rule. A hidden ROM is reported as unavailable rather than revealing that a session exists. The room URL is built for the browser-facing host, while broker credentials and server paths remain on the backend.

References: backend/…/streaming.py• L1359-1433 backend/…/streaming.py• L1790-1833 backend/…/access.py• L60-117 backend/…/config.py• L253-339 frontend/…/Stream.vue• L143-161 frontend/…/Stream.vue• L965-974

Administrative streaming sessions

Administrators can inspect sessions by container and can open a supported container desktop without starting a game. A desktop session uses the same exclusive claim as a game, so it reserves the display for setup and prevents a player from launching over it.

Administrators can force-release active sessions. The sweep uses the same guarded teardown as a single administrative release for each configured session. It marks the session as draining before broker work, records the termination notice before stopping the emulator, and performs the same card, activity, play-history, state, and save work before it removes the claim. If the container configuration is gone, RomM cannot stop a broker, but it still records the termination and closes the session record before releasing the claim. A broker or cleanup error does not stop the sweep from releasing its claim. A session already draining is left to finish its protected cleanup.

An administrator may operate a session owned by another user, but new state and save data remain attached to the original claimant's library. If more than one session is active for a platform and the administrator does not name a container, the API rejects the request instead of choosing one by accident.

References: backend/…/streaming.py• L1641-1787 backend/…/streaming.py• L1836-1941 backend/…/access.py• L34-51 backend/…/access.py• L214-262 backend/…/lifecycle.py• L384-554

Play history

Both browser play and streamed play record a play session after gameplay starts. The record supplies the user's play history and updates the ROM's personal play markers without making navigation wait for the history request. Streaming records its entry during teardown, so normal exit, administrator release, and abandoned-session cleanup use the same accounting path.

Session recording

The v2 player starts a wall-clock session when the stream is live. A joining viewer flushes that local session on exit because the viewer does not own the host claim. The host's play record comes from backend teardown, so a closed tab or force release does not depend on the browser flush. On unmount, the frontend still uses a keepalive request for the local session record while the page is leaving.

The backend accepts a bounded batch of session entries, rejects invalid times, and marks repeated entries as duplicates. For a new session it updates the user's latest play time and active-play marker only when the session is newer than the current record. Streaming treats a play-history failure as non-fatal to cleanup and ignores sessions shorter than the accidental-claim threshold.

References: frontend/…/index.ts• L1-59 frontend/…/Stream.vue• L856-868 frontend/…/Stream.vue• L1411-1418 backend/…/lifecycle.py• L268-395 backend/…/play_sessions.py• L23-95

API boundaries

The API boundaries separate room coordination, emulator control, shared-session joining, persistent-data transfer, and play-history writes. Realtime events provide fast feedback, while status and stored termination notices let the player recover when a socket event is missed.

AreaMain interfaceOwnership rule
Netplay discoveryGET /api/netplay/listAuthenticated read of rooms for one game
Netplay realtime/netplay/socket.ioSocket membership controls room actions
Stream setupGET /api/streaming/config, GET /api/streaming/states/{rom_id}, and POST /api/streaming/sessionsStreaming visibility plus read/write access for the claiming user
Stream launch statusstreaming:launch-ready, streaming:launch-failed, streaming:launch-phase, plus GET .../statusRealtime push with polling fallback
Stream termination noticestreaming:session-ended, plus GET .../statusBest-effort push with a stored notice for recovery
Stream control/api/streaming/sessions/{platform}/...Claiming user or administrator with a matching claim
Shared streamingGET /api/streaming/sessions/joinable and POST /api/streaming/sessions/{platform}/joinJoin permission and ROM visibility; host keeps control
Broker control and transferPrivate broker HTTP APIBackend-only access with bounded requests
Play historyPOST /api/play-sessions and streaming teardownUser write access and per-user records

The browser receives only the host needed to display the stream and the typed status needed to recover its lifecycle. The backend keeps broker credentials, library paths, and ownership checks out of the browser. State and save data move through the backend so storage ownership remains tied to the claimant even when an administrator operates the session.

References: backend/…/netplay.py• L55-77 backend/…/streaming.py• L342-439 backend/…/streaming.py• L1339-1433 backend/…/access.py• L34-155 backend/…/access.py• L265-326 backend/…/session_store.py• L683-770 frontend/…/Stream.vue• L614-730

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the netplay Socket.IO path aligned across the backend mount and the EmulatorJS client patch. A mismatch breaks room actions even when the game player loads.
  • Keep room admission checks aligned between the room list and the join handler. A list that shows a full or wrong-game room creates a silent join failure.
  • Keep streaming permission checks aligned across configuration, claim, control, release, and shared-session routes. Read access for joining must not become permission to claim or drive an emulator.
  • Keep the user-write scope on every mutating streaming route. A shared kiosk identity must not claim, control, or release another user's session.
  • Keep platform and ROM visibility checks aligned across config, claim, busy-session details, shared-session listing, and join. A hidden title must not leak through a session name or room URL.
  • Keep named container resolution and claim stamps aligned with pool resolution. A tab must not control a replacement claim, and an administrator must not release an ambiguous pool member.
  • Keep the streaming container identity as the broker identity. Changing host or broker-host derivation can allow duplicate claims or make old sessions impossible to release.
  • Keep platform-specific container records aligned with the shared container key. A session that serves several platforms must resolve its saves and cards from the claimed platform rather than an arbitrary record.
  • Keep absolute stream URLs, same-origin proxy paths, broker addresses, and webstation subfolders consistent. A browser-reachable stream is not enough for backend control.
  • Keep the broker protocol and declared import spec aligned with the controls and foreign save or state types that the player offers.
  • Keep compatible pool members aligned on emulator, core, memory-card mode, save-picker behavior, broker protocol, and experimental-core policy. A pool that mixes save namespaces or controls can hydrate data into the wrong emulator or show controls that fail on some claims.
  • Keep capability tables aligned with broker behavior and the /config response. The player must not offer a state slot, autosave, disc action, memory card, or save picker that the broker cannot support.
  • Preserve the distinction between save states, emulator-native save data, and whole memory cards. Each type has a different boot, sync, and ownership path.
  • Preserve normalized ROM and UI language hints when changing launch inputs. Unknown language values must remain optional so they do not block a launch.
  • Preserve archive manifest rules, safe member names, expanded-size limits, member-count limits, and broker refusal details when changing foreign save or state imports.
  • Preserve bounded broker reads, archive member limits, body limits, and per-operation deadlines. A slow or oversized broker response must not hold a request or exhaust backend memory.
  • Preserve the shared teardown order used by owner release, administrator release, stale-session takeover, and force-release-all. Record termination before broker stop, keep the claim protected through card and exit-data work, and use guarded release when configuration is missing.
  • Preserve compare-and-set session writes, stale-heartbeat takeover, drain-marker rules, claim stamps, and termination notices. A late update must not resurrect an old claim, a stale session must be safe to stop, and the player must not act on a notice for another claim.
  • Preserve the play-session minimum and idempotent ingest behavior when changing streaming exit paths. Cleanup must not lose playtime or create duplicate records.
  • Keep join mode separate from claim mode in the player. A joiner must not send owner-only resume, heartbeat, save, or release requests, and its unmount must not release the host's claim.
  • Keep the netplay cleanup schedule aligned with the room storage model. The task must delete only rooms with no players.
  • Keep broker protocol translation aligned with room URL rules and broker response fields. A returned room must stay on its configured host and must carry the access data needed by that protocol.
  • Keep state history and launch selection aligned with the active RetroArch core and its library folder aliases. A state from another core must not be offered for resume or written into the active core's slot.
  • Keep webstation export collection paired with archive deletion. A change that downloads without removing an export can replay old saves on a later claim.
  • Keep the player’s fresh capability and state-pick response aligned with the save and state IDs sent in the claim. A stale picker must not send an asset that the backend no longer offers.
  • Keep RetroArch exit parsing aligned with autosave lineage and the shared core folder. A split exit must not create duplicate saves or hide state captures from other clients.
  • Keep save-pull pending markers aligned with exit archive collection. A later claim must not hydrate before the prior session's delta is filed, and an old pull must not clear a newer marker.
  • Keep archive overlay identity aligned with the restored save's content hash. A changed base asset must not receive a delta from an earlier launch.
  • Keep shared not-found behavior aligned for missing and hidden ROMs across netplay discovery, stream setup, state picks, and shared-session joins. A route that returns a distinct error can reveal library access or expose a different launch path.

Important failure modes

TriggerConsequenceGuard
Two users claim the same emulator containerOne launch is rejected and the holder details are returnedAtomic Redis claim keyed by broker container
One user sends two claims for a pooled platform at onceThe user can hold two containers while the second request becomes hard to reachPer-user and per-platform claim gate around reservation
A user has read access but not streaming write accessThe player can see setup data but cannot claim or control a sessionSeparate read and write permission checks
A kiosk identity sends a session writeShared kiosk state could alter another user's sessionRequire the user-write scope for all mutating stream routes
A hidden platform or ROM appears in stream config or join detailsA user can learn about library content they cannot accessApply visibility checks before returning config, session details, or room URLs
A missing or hidden ROM gets a distinct discovery or setup responseThe API can reveal whether a library record exists or offer a different access pathUse one not-found helper for ROM lookup and visibility checks
A named claim is replaced before a control or release arrivesA late tab can stop or alter a newer sessionMatch the container and claim timestamp before mutation
Configured pool members use different save namespaces, card modes, cores, or protocolsA session can land on a container that cannot read its data or honor its controlsAdmit only interchangeable containers to a platform pool
A same-origin stream path has no named broker addressThe browser can see the stream but the backend cannot control the emulatorRequire a derived or explicit server-side broker address
Webstation host path does not match its broker subfolderLaunch room URLs can point to the wrong mounted pathReject a webstation entry whose host path disagrees with its subfolder
Broker returns a room URL outside its configured hostA joiner could be sent to an unrelated originResolve only same-host room URLs and fall back to the configured host
Broker receives an unknown or malformed language valueA multilingual title can start with the wrong variant or reject the launchReduce known names and locales to codes and omit unknown values
Broker starts a different configured RetroArch coreState and save data can be filed for a core that cannot load themCompare the broker's reported core with the configured core and stop unsafe state use
Broker returns a slow or oversized responseA worker can remain blocked or memory use can grow without boundWall-clock transfer limits and response size limits
A foreign save or state archive contains unsafe, excessive, or refused membersThe launch cannot restore the selected assetFilter archive members, enforce size and count limits, and surface broker refusal details
Webstation leaves an exit archive after RomM pulls itA later launch can see stale save data or the container can fill with old exportsPull from the export list by broker session and remove each archive after receipt
A restored save changes before exitThe exit delta can be merged into the wrong library versionStore and compare the restored save's content hash before overlay
Broker launch fails after a claimThe container would remain blockedAbort the claim and publish streaming:launch-failed
A claim fails after a temporary memory card is createdAn unused card would remain in the user's libraryAbort the claim and discard the temporary card
Whole-card sync is enabled for a platform without a cardFile-based saves can stop syncing while an empty card is movedIgnore card sync for known cardless platforms
Whole-card hydration or evacuation failsOne user's card can leak into another session or be wiped at the wrong timeTreat card sync as a protected claim and teardown step
Save data is hydrated after game bootThe game may start with old in-container dataHydrate emulator-native saves before launch
Navigation starts a new claim while save-and-exit still runsThe new ROM can overwrite the old emulator before its save finishesDrain marker and teardown reservation
A later claim starts before an exit save pull finishesThe new session can restore a stale archive and lose the prior deltaPer-user and per-ROM save-pull marker with bounded wait and token-guarded clear
A late heartbeat or launch callback writes over a new claimA fresh session can lose its state or receive an old session's metadataGuard session mutations with compare-and-set claim identity
A status or termination event belongs to another tab or later claimThe player can leave a live session or show the wrong end reasonMatch container and claim timestamp before changing the view
A joiner sends an owner-only request or unmounts without stable join modeThe host's game can receive an invalid control or the host can be releasedRead join mode from the destination and block claim-only controls and teardown
User leaves without a clean releaseThe emulator can remain reservedHeartbeat staleness takeover plus protected cleanup
Teardown fails after the API returnsA phantom claim can block later playRelease the claim in the teardown finally path
An administrator force-releases while a session is already drainingExit state or card data can be lost, or a new claim can start too earlySkip active drain markers and let the protected teardown finish
A session's container configuration is removed before force releaseThe broker cannot be stopped, but the claim must not remain phantomRecord termination and close the session record, then use guarded claim release
Room owner disconnectsRemaining players lose the owner roleAssign ownership to a remaining player
Empty room survives an abnormal pathStale room data appears in room storageImmediate empty-room deletion plus scheduled cleanup
User joins a full or wrong-game roomThe room action fails after discoveryFilter open-room listing and recheck at join time
A streaming host shares a container without join supportJoiners receive a session that cannot seat themOnly advertise and accept sessions on containers that support joining
A joiner uses an owner-only route or unmounts the shared playerThe host's game could be changed or released by a viewerKeep join access read-only and track the local tab as a joiner
An administrator controls another user's sessionNew state or save data could be filed under the administratorResolve storage ownership from the claiming user
Older play history arrives after a newer sessionCurrent play markers could move backwardApply ROM-user updates only for the newest end time
A state from another core is offered to a RetroArch launchThe broker may reject it or quick-load the wrong fileFilter state picks and hydration by the active core and library folder
The state-pick response is missing or stale when Play sends a selectionThe backend can reject a valid-looking choice or launch without the intended resume pointRefresh picks before Play and send only an explicit visible selection

Key files

FileWhy to read it
backend/…/netplay.pyDefines room creation, joining, departure, peer signaling, and room event relay
backend/…/netplay.pyDefines the room discovery contract, visibility handling, and open-room filtering
backend/…/netplay_handler.pyDefines the shared room state stored in Redis
backend/…/cleanup_netplay.pyShows the fallback cleanup for empty rooms
frontend/…/Player.vueShows how the browser player connects EmulatorJS to room discovery and realtime netplay
backend/…/streaming.pyDefines stream configuration, ROM visibility, claims, launch status, controls, shared joining, ownership, desktop sessions, and release behavior
backend/…/access.pyDefines streaming permission checks, session ownership, claim selection, claim stamps, and platform and ROM visibility checks used by stream routes
backend/…/config.pyDefines stable container identity, platform-specific records, broker routing, compatible pools, save namespaces, and resolved platform capabilities
backend/…/capabilities.pyDefines the supported state, autosave, memory-card, disc, and transfer limits that shape the player contract
backend/…/protocol.pyDefines the common boundary between webstation and legacy broker routes, features, and stream URLs
backend/…/broker.pyDefines the bounded server-to-server transport used for broker control and file transfer
backend/…/archive.pyDefines the bounded broker archive manifest, member reads, and archive overlays used by import and exit-save flows
backend/…/webstation.pyDefines webstation activation, import discovery, core folder discovery, room joining, and export collection
backend/…/imports.pyDefines cross-emulator save and state import archives and their safety limits
backend/…/launch.pyRuns detached launches, keeps the claim alive, publishes launch progress and readiness, and aborts failed launches
backend/…/session_store.pyDefines atomic claims, guarded session updates, liveness, drain markers, save-pull-safe termination, and termination notices
backend/…/lifecycle.pyDefines the shared order for claim abort, session teardown, stale-session recovery, activity, playtime, and exit-state handling
backend/…/states.pyShows how state picks, core-aware resume, central state history, screenshots, and container transfers work
backend/…/memory_cards.pyDefines whole-card hydration, adoption, evacuation, and wipe rules
backend/…/saves.pyShows how emulator-native save data, exit archive deltas, RetroArch autosave lineage, and save-pull ordering move between containers and user assets
frontend/…/Stream.vueShows the launch screen, broker-selected resume choices, stream shell, claim-aware realtime handling, joiner behavior, controls, and exit cleanup
frontend/…/index.tsShows how active play becomes a history record on exit
backend/…/play_session_handler.pyShows deduplication and the side effects on the user's ROM play state

See also Play and client services, Play sessions and saves, and Remote library sync.