Files
2026-07-14 00:41:05 +02:00

55 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Game Activity
> **Status:** Active
> **Last updated:** 2026-07-05
## Overview
"Now playing" game detection: Electron foreground-window/process heuristics, RAWG metadata match via signaling server, and P2P `game-activity` broadcast to peers. Shown on profile cards and room sidebars.
## Responsibilities
| Layer | Owns |
|-------|------|
| `game-activity` domain | Scan loop, confidence scoring, P2P broadcast, user store updates |
| Electron IPC | `get-running-process-names`, `get-active-game-candidate` |
| Signaling server | `POST /api/games/match` (RAWG proxy + miss cache) |
| P2P | `game-activity` data-channel event |
## Server API
### `POST /api/games/match`
- **Auth:** Public
- **Body:** `{ processNames: string[], candidates?: { processName, score }[] }` (bounded list sizes)
- **Response:** `{ game: MatchedGame | null }` — RAWG-backed title, cover art, store links
Misses cached in server SQLite (`GameMatchMiss`) to limit API calls.
## Client detection
- Periodic scan (default 10 s, configurable 560 s in localStorage `metoyou_game_scan_interval_ms`).
- Ignores launcher/helper processes via `IGNORED_PROCESS_NAMES` and regex patterns.
- **Electron:** suppresses scan when MetoYou window is focused; prefers foreground-window candidate from `get-active-game-candidate`.
- **Browser/Capacitor:** no process scan — activity only from P2P peers.
## P2P event
```json
{ "type": "game-activity", "activity": { "game", "startedAt", "processName", ... } }
```
Peers merge into `User.gameActivity` in NgRx store.
## Related
- [signaling.md](signaling.md) — not WS-relayed
- [server-directory.md](server-directory.md) — API base URL for match endpoint
- Domain README: [`toju-app/src/app/domains/game-activity/README.md`](../../toju-app/src/app/domains/game-activity/README.md)
## Changelog
| Date | Change |
|------|--------|
| 2026-07-05 | Initial cross-context game-activity contract |