Playing live: WebRTC and WebSocket together

On 1 April 2026 the project gained a hybrid of two ways to connect players: WebRTC, which links the browsers of the players directly, and a WebSocket connection to the server. The server connection always works; the direct link is faster when it is possible.

Why two connections

A server in the middle is reliable, but every message travels to the server and back. A direct link between two players is quicker, but it does not always work: some networks block it. Using both gets the speed when it is available and keeps the game alive when it is not.

How it works today

In the current version, every player in a room keeps a WebSocket to the server, and the players also try to connect to each other directly. Messages go over the direct link first; if it is not there after a short time, they go through the server instead. A player can lose one of the two and still keep playing.

In plain words

A WebSocket is a long-lived connection between your browser and a server, over which both sides can send messages at any time. WebRTC is a way for two browsers to talk to each other without sending everything through a server. TypeLemon uses the first for reliability and the second for speed. It does not run a media relay of its own for the direct links: when a direct link is impossible, the server connection carries the messages.

Knowing who is still there

The server also keeps a light check on who is still in a room. A player who goes quiet for a while is announced to the room, so the others do not wait for someone who has left. A player who comes back within a short time gets the seat back.

Why not only WebRTC

Not every network lets browsers connect to each other. School and office networks are often the strictest. A site meant for classrooms cannot depend on a connection that the classroom network refuses, so the server connection stays.