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.

PLAY TETERI ALL ARTICLES