PintaFesta — architecture at a glance

The host phone is the only server: it binds one HTTP socket, one WebSocket socket, and hands out the pages for every other screen.
Local network only. Four front-ends render the same game state, in two languages, and share no code.
NATIVE (Kotlin) — runs inside an installed copy of the app
WEB ASSETS (HTML / CSS / JS) — static files served by the host
TV — just a second browser window, not another install
SERVER — HTTP :8080 and WebSocket :8081, host phone only
WARNING — a constant is duplicated; change every copy
GUEST DEVICES
one per player — an Android phone or any browser

NATIVE PLAYER

ui/PlayerActivity.kt — its own copy of the app

BROWSER PLAYER

assets/play/ — index.html, play.js, style.css, avatar.css

NO SHARED CODE

RULES AS CODED

THE HOST IS ALSO A PLAYER

HOST PHONE
com.pintafesta — one Android process, one install, the only server in the game

HostActivity.kt — the host's own screen

GameService.kt — owns the authoritative GameState

lives as long as the Activity; start() runs on its own thread

HttpServer.kt

TCP 8080 — hand-rolled HTTP/1.1, one thread per connection
GET / landing page
GET /tv/ tv/index.html
GET /tv/* tv/*
GET /play/ play/index.html
GET /play/* play/*
GET /api/info
GET /api/health
GET /api/qr?text=
404 for anything else

/api/info hands out host, httpPort, wsPort and both URLs; /api/qr renders a PNG with ZXing.

WsServer

TCP 8081 — Java-WebSocket 1.5.4, bound to 0.0.0.0
Role is read off the
handshake, never logged in:
/tv → Role.TV
/play → Role.PLAYER
?role=tv|player|host

Broadcasts snapshot the connection set and drop dead sockets: a concurrent modification here used to swallow a whole ROUND_START and strand the TV on the lobby.

Everything the browsers need ships inside this APK

the host app's assets/ folder is the whole web front-end

What this shape buys, and what it costs

TV SCREEN
a second browser on a big screen, not another install

TV — assets/tv/

index.html, tv.js, style.css, avatar.css

How the TV gets its data

The TV is a viewer, not a player

FOUR FRONT-ENDS, ONE SERVER

What the two servers split

HTTP
:8080
GET /play/ index
GET /api/info
(browser player only)
WS :8081
WELCOME, TICK,
ROUND_END,
GAME_END, ERROR
SOLVE_COUNTS
JOIN, GUESS,
DRAWING, PING,
SUBSCRIBE
HTTP
:8080
GET /tv/ index
GET /api/qr?text=
WS :8081
DRAWING,
SOLVE_COUNTS,
ROUND_END,
GAME_END
SUBSCRIBE role=tv
(lite poll, 4 s)

CLIENT → SERVER — WebSocket :8081

one JSON object per message: { "type": "<TYPE>", ...payload }
JOIN{ nickname, lang, avatarId }
GUESS{ text } targetId optional
DRAWING{ dataUrl } one per 2 s, webp q55
SUBSCRIBE{ role } lite:true skips the snapshot replay
PING{} answered with PONG
START_GAME / NEXT_ROUND / END_GAMEhost only, and in practice unreachable
OPEN_TVdeclared in Protocol.kt, never handled by dispatch()
The native player derives the WebSocket port as http port + 1;
both browsers read it out of /api/info instead.

SERVER → CLIENT — WebSocket :8081

a correct GUESS_RESULT goes to everyone; the private variants go only to the guesser
WELCOME{ playerId, serverTime, lang } joiner only
LOBBY / ROSTER{ players[] } lobby, then mid-round changes
ROUND_START{ round, durationSec, endsAt, players[],
yourWord, resumeSnapshot, solvedTargetIds } per connection
TICK{ remainingSec } once a second
DRAWING{ playerId, dataUrl } to Role.TV and Role.HOST only
SOLVE_COUNTS{ counts[] } after every correct guess
GUESS_RESULTcorrect → everyone; wrong, alreadySolved, noMatch → guesser
ROUND_END / GAME_END{ scores[] } also ERROR { code, message }

Rules every client has to obey

Duplication traps — change these in every copy

Build and packaging

Read out of the source on branch main, 2026-10-04. Ports from Constants.DEFAULT_PORT (8080) and 8080 + 1; the two message directions from Protocol.kt and GameService.dispatch().