TETERI
How TETERI is built
Online Play With No Server At All
WebRTC connects the two browsers directly; a public relay handles only the introduction.
TETERI is a directory of static files on a static host. It has online multiplayer anyway.
The trick
WebRTC lets two browsers open a data channel directly to each other. Once established, no server is involved in the traffic at all.
The catch is the introduction. Two browsers behind different networks cannot find each other unaided; they need to exchange connection details first. That exchange needs some third party to pass messages, and it is the only part that does.
Using a relay as a dumb pipe
TETERI connects to a public PeerServer instance over a WebSocket, but does not use its client library or its abstractions. It uses the server purely as a message relay: the message types it agrees to forward carry an arbitrary payload, and both ends of that payload are our own code.
Send an offer, receive an answer, exchange candidates, connection established, close the socket. The relay never sees game data.
The second transport
For two tabs on one machine, even that is unnecessary. Ticking same device in the lobby swaps the relay for a BroadcastChannel, which is the browser's own mechanism for messaging between tabs of the same origin.
Same WebRTC code, same handshake, no server of any kind. It is also how the whole stack gets tested, since a test can drive both sides in one browser.
What crosses the channel
A board snapshot about fifteen times a second, as a compact object with the grid encoded as a string, plus discrete events for attacks and knockouts. A snapshot serialises to under 700 bytes, so the whole thing runs comfortably in single- digit kilobytes per second.
Fairness without authority
There is no authoritative server, so both sides simulate independently. That works because the two games never need to agree on anything continuous. They share a seed, so the piece sequences match, and they exchange attacks as discrete events. Nothing to desynchronise.
The honest weakness
The public relay is convenient, not guaranteed. If it is rate-limited or down, room-code play fails. The game says so plainly, and you can point it at your own relay with a query parameter.
Read next
- Rendering: Sprite Caches and Layer BakingDrawing four hundred glowing blocks per frame is slow. Drawing four hundred cached bitmaps is not.
- Every Sound Is Generated, Not RecordedOscillators, filtered noise and a reverb impulse built from decaying random numbers. No audio files anywhere.
- The Soundtrack Is a Sequencer, Not a FileA four-bar progression with drums, bass, arpeggio and a lead, whose tempo and arrangement climb with your level.
- Seeded Randomness: Why Both Players Get the Same PiecesA small deterministic generator, one shared number, and two identical bags on different machines.
- How the Hold Slot WorksPark one piece for later, but only once per piece, which is what makes it a decision rather than an undo button.
- Keep the Stack Flat: The One Habit That Matters MostA flat surface accepts every piece. A jagged one accepts a few. Most runs end because the board stopped accepting what the bag offered.