[Feature] Live socket events for clients signed in with a client token (device pairing)

Open
#5,849 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start by reading endpoints/sockets/logs.py and comparing the main and netplay namespace connection handlers with the /devices namespace’s client-token handling. Trace /api/auth/device/init and /token, then identify where users join user:<id> rooms and where emit_to_user targets them. Done means paired clients can authenticate to the relevant sockets, receive their permitted live events, and open netplay rooms, with appropriate scope and revocation checks.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.
Clients that sign in through device pairing (/api/auth/device/init + /token) get a client token, which works for the whole REST API. But the main Socket.IO namespace (/) only recognises the web session cookie (endpoints/sockets/logs.py connect reads the session from the environ), so a paired client never joins user:<id> and never receives notifications:new, activity:update or any other per-user event. The same goes for the netplay namespace: a socket without the web session has no user, so it can join a room with its password but cannot open one.

The result is that a TV or handheld client signed in the recommended way has to poll for everything, and features built on notifications (5.5) only work on clients that also hold a web session.

Describe the solution you'd like
The /devices namespace already does the hard part: it accepts a device-bound client token (handshake auth.token or Authorization: Bearer), checks it, tracks the socket for revocation and closes it on expiry. Either of these would close the gap:

  • on /devices connect, also enter a per-user room for the token's owner in that namespace, and have emit_to_user emit there too (so notifications and activity reach paired devices), or
  • accept a client token on / (and on the netplay namespace) the same way, resolving the user and joining user:<id>, with a scope check (for example notifications.read for notifications, me.read to connect at all).

Describe alternatives you've considered
Polling GET /api/notifications and GET /api/activity every 10-40 s, and asking users to also sign in on the web page inside the app just to get a cookie for the socket. In Arcade TV (an Android TV client for RomM) a TV signed in with a code can't open a netplay room and gets no live updates, so it shows a "Turn on messages and parties" prompt that sends the user to the web sign-in.

Additional context
Mentioned briefly in a comment on #5831. Device presence (device_presence:<id>, 90 s TTL) would also become meaningful for these clients once they hold a socket.

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.