Guide › Broadcast
Broadcast
The Broadcast tab of a running tournament publishes it while it plays; the snapshot is refreshed twice a second. Game shown picks the game sent to TLCS and the web page: automatic, or the one chosen in the Live tab.
Live files
Written atomically in a folder of your choice, to publish anywhere (FTP, rsync, a website): live.pgn (the games in
progress), standings.html (standings and crosstable), tournament.json (everything, for scripts).
TLCS server
UDP port, 16001 by default: the protocol of Tom’s Live Chess Server, so TLCV and other TLCS viewers can follow the tournament (board, clocks, PV, crosstable and the games played). It is checked against node-tlcv. One port per game puts every concurrent game on a port of its own: game #1 of the Live tab on the UDP port, #2 on the next one, and so on. Each port opens when its game starts, with its own limits on clients and logons, and gets the crosstable after every game; Game shown then does not apply.
Web page
TCP port: a page served by RookStudio itself, for any browser on the network, read-only and refreshed every second. The followed game (the first in progress, or the one clicked) is in the middle: the board with the last move, a king in check, the coordinates and the arrows; each player’s clock in large type; each engine’s evaluation in large type with who is thinking, its search as tiles (depth/selective depth, nodes, speed, time, tablebase hits, hash) and its line of play; and the moves, with the book moves in italics. Step through the moves with the arrows under the board or the ← → keys (▶ past the last move goes back to the game as it is played), turn the board with ⇅ or F, and copy the game’s PGN or the position’s FEN.
Beside the game, tabs show the standings and crosstable, the charts of the followed game, each engine’s search on
average per move with its anomalies, the next games of the schedule (a Swiss or a knockout pairs its later rounds as
it goes), the statistics and anomalies of the games played, and the event. Every game in progress is shown below,
with a small evaluation bar beside each player. Moves switches the moves between letters (Nf3) and figurines (♘f3),
and the theme follows the system or is set to light or dark; the browser remembers these choices. The page loads
nothing from elsewhere and works on phones. Download the games (PGN) gives the tournament’s PGN file, up to the last
game recorded. state.json, which the page reads, holds all of it for scripts. The engines’ logos (see
Appearance) show beside their names, as small PNG pictures the program makes from them and serves
itself; the page learns only those of the tournament’s engines.
lichess
A lichess broadcast, with lichess’ board, evaluation bar and chat, for anyone on the internet. It needs a personal
API token with the study:write scope (Create a token on lichess…), kept in settings.json in the profile only,
saved when its field is left. With no round given, a broadcast named after the tournament is made, unlisted unless
Listed among lichess’ broadcasts is ticked; its link is shown once it is on air. Otherwise the games go to the round
whose URL or id is given (a broadcast fed by pushes, not by a source URL). The games in progress are pushed every 8
seconds with their clocks, and each finished game once; a round holds 64 games, after which the next round of the
same broadcast is made. Only the games finished after it was switched on are pushed; lichess.json in the tournament
folder remembers where they went, so a resumed tournament continues the same broadcast. lichess keeps only the clocks
of what it is sent (it drops the [%eval] and the text of the move comments): its evaluation bar is its own, and the
engines’ evaluations do not show there.
The connection uses Mbed TLS, built into the program, and trusts only the root certificates that sign lichess.org
(Google Trust Services) and those of Let’s Encrypt. It goes through the HTTP proxy that HTTPS_PROXY (or ALL_PROXY)
names, as http://proxy.example:3128 or http://user:password@proxy.example:3128, except for the hosts of
NO_PROXY; on Windows too the proxy comes from these variables, not from the system settings. SOCKS proxies are not
supported.
Your own Lichess broadcast
Broadcast on Lichess…, in the header of a tournament that plays on this machine, opens a sheet: the broadcast’s name (the tournament’s at first), unlisted (for those who have its link) unless Public: listed on Lichess is chosen, and what goes to Lichess, the name, the tournament’s format and time control, and each game’s PGN. Create the broadcast asks your linked account for one more permission the first time, creating studies and broadcasts (Lichess’s page opens for it), or links the account with it; the token pasted in the lichess card above serves when no account is linked. Then the games go to the broadcast as described above, and a banner under the header says how many were sent and when the last one was, with Open on lichess.org and Stop.
A team match on the air
A team match shows the teams’ score everywhere: in the web page’s header and above its standings (with team A’s
score %, Elo ± and LOS), in standings.html (the teams, then each team’s engines against the other team’s), in
tournament.json and state.json (teams, team_elo, team_elo_error, team_los), and in the TLCS crosstable, as
a line under the table (“Lynx 17½ - 18½ Otter · 48.6 % · Elo -9.7 ± 31.2”). Its games carry WhiteTeam and
BlackTeam tags in the PGN files, which the exports keep.
Putting the web page on the internet
The web page can be followed from anywhere without opening a port in the router: tick Publish on the internet under Web page in the Broadcast tab. While a tournament runs, RookStudio opens an SSH tunnel (libssh2, built into the program) to a tunnel service, which gives the page a public https address; nothing needs to be installed.
- localhost.run (the default): free, without an account. Its addresses change now and then, and its speed is limited; the page and its state are sent compressed, so this does not matter much. Its host key is known to RookStudio: a connection to anything else is refused.
- Another SSH server: its host, port and user, and the port it opens for the page (as
ssh -R REMOTE_PORT:localhost:PORT user@hostwould ask; 0 lets it choose). Only servers that let the user in without a key or a password can be used (authentication “none”), and they must offer curve25519-sha256, an RSA host key of 2048 to 4096 bits, and AES (GCM or CTR). The server’s key is trusted the first time and kept in the profile (known_hosts.json); if it changes, the tunnel stops and says so, and Trust the new key is for when the server’s owner confirms it changed.
The tab shows the state (connecting, on air with the number of connections, reconnecting, or an error) and, once known, the public address with Copy, Open (to see the page as viewers do) and a QR code for a phone (click it to enlarge). The tunnel reconnects by itself after a failure, waiting a little longer each time, and shows the new address if it changed. It stops with the web page or with the tournament.
Other tunnels work too, started separately: with Cloudflare’s, for example, switch on the web page (port 8080 here)
and run cloudflared tunnel --url http://localhost:8080; it prints an address such as
https://some-words.trycloudflare.com. ngrok, tailscale funnel or a reverse proxy such as nginx, under a path of its
own as well (location /live/ { proxy_pass http://localhost:8080/; }), work the same way.
The page is read-only: it answers only GET requests for the page, its state and the PGN file, never a file a request names, and nothing in it changes the tournament. Each request is answered on its own, 32 at a time at most, and must arrive within a second and be answered within ten, so a slow or silent visitor holds no one else; behind the tunnel each viewer’s connection counts as one of those: 40 are relayed at once, as many more wait their turn, and the next are refused; a viewer who sends more than the page takes is let go alone. Two downloads of the PGN file run at once, and the next is asked to come back a moment later. The state is never cached, by the tunnel either, so viewers see the games as they go; the page is kept by the browser and checked again at each load. The viewers shown in the Broadcast tab are counted from the requests the pages make, so the count is right behind a tunnel too.
Viewers see the tournament’s name, the engines’ names, their ratings, searches and anomalies, the openings and the PGN file of the games played. The folders and the engines’ files stay private. Headless:
rookstudio --run FOLDER --tunnel # localhost.run, the address printed on the console
rookstudio --run FOLDER --web 8080 --tunnel ssh://user@host[:port][/remote_port]
Where the viewers talk
The page has no chat of its own; it points to where the talk happens. A Chat link under Web page (a Discord invite, a Twitch channel, a forum thread; https only, anything else is refused with a message under the field) puts a Chat button in the page’s header that opens it in a new tab. While the games are pushed to lichess, the page also links to the lichess round, which has its own chat.
A Discord server ID adds a Discord tab beside Event, with Discord’s own server widget in the page’s light or
dark theme: the server’s name, the members online, its voice channels and a Join button, not the messages. The
server’s owner switches it on in Server Settings, Widget (“Enable Server Widget”), which also shows the server ID to
copy (17 to 20 digits); with Developer Mode on, right-clicking the server’s icon gives Copy Server ID as well. The
widget is loaded from discord.com only once a viewer opens the tab, and Discord then sees that viewer’s visit (their
address, their browser, their Discord login if they have one); without an ID, the page contacts nobody but
RookStudio. The chat and lichess links send nothing until a viewer clicks them, and then no referrer. A setup file
run headless (--run SETUP.json) takes both from web_chat_link and web_discord_id.