What it is
The authoritative half of RareIcon. Headless — no window, no renderer, no asset
loading. It owns where everybody is and tells the clients about it. The art, the
tilesheets and the camera belong to apps/rareicon/game, and none of them are
linked here.
Built on lightyear over Bevy. The
wire is crates/mmorpg_net’s dim2 — the same crate the client links with the
same feature, so the two cannot drift apart without one of them failing to
compile.
It is a library as well as a binary. The game links the same rules and runs
them in-process as its offline world, so there is no second copy of them to
drift; the sockets, the HTTP door and Agones sit behind the deploy feature,
which the client leaves out.
What is authoritative
Positions. A client sends which keys are down and never a position. The server
integrates that intent against the same walk rule the client predicts with —
mmorpg_net::dim2::walk, where collision and terrain live too — and the client
rolls back when the two disagree. A client that lies about its keys can walk at
walking speed in a direction of its choosing, which is what a player can do
anyway.
Everything a player does that costs or earns is ruled here, never taken from a client’s word: a strike lands only if both bodies are alive, on one level and in reach by the positions this process holds, with the cooldown up; a catch lands on casts this end counted; deeds, crafting, gathering, trade and purses are the server’s to settle.
Most of the process is the world itself: villagers with jobs and wages, towns, caravans and carts, farms, beasts and companions, estates and deeds, and the War Sim’s battles. Towns nobody is near go dormant and wake when a player comes back.
Two lanes into one world
| Lane | Port | Who uses it |
|---|---|---|
| UDP | 7985 | native clients, through an L4 LoadBalancer |
| WebSocket | 7986 | browsers, which cannot open a UDP socket at all, at wss.rareicon.com |
| HTTP door | 7987 | /token, /lobbies and /healthz, through kbve-gateway |
Both game lanes land in the same world, and nothing after admission knows which
way a player arrived. lightyear refuses an app with more than one started
Server, so both sockets hang off a single server entity.
Admission
A player asks POST /token before opening anything, and is given a signed
ConnectToken. Admission is HTTP because a browser cannot put an
Authorization header on a WebSocket — you cannot present a credential on the
socket you are trying to open.
It also keeps the signing key server-side. Who the player is travels inside
the token’s signed user_data, and the game server reads it back rather than
being told, so a client cannot rename itself.
The door tries, in order: a Supabase access token (verified with jedi’s JWKS
verifier, HS256 or ES256; the name is the kbve_username claim), a Steam
ticket checked against the publisher key for the apps in STEAM_APP_IDS, a
client-kept secret that hashes into a guest who comes back as the same guest,
and finally a fresh guest. A credential that does not verify falls through to
the next rather than refusing, so a lapsed session costs a player their name,
not their evening. The image is built with --features agones,supabase.
/lobbies lists the public rooms hosts have announced, for the site’s list.
In the cluster
The agones feature links the SDK: Ready() once the sockets are actually
listening rather than at startup, a health ping inside the sidecar’s deadline,
and a watch that exits the process when the cluster moves the GameServer to
Shutdown. Superseded by a Fleet update, the server tells every player the
world is closing for an update, refuses new tokens a minute later, and leaves;
the client knocks again until the new server is up. It is off by default — the
SDK talks to a sidecar that only exists in a pod — and the image build turns it
on.
GitLab CI builds the image from apps/rareicon/server/Dockerfile and publishes
registry.gitlab.com/kbve/workspace/rareicon-server (apps/rareicon/ci.yml).
One pod, on purpose: everyone lands in the same world, and the single public UDP
address assumes it. See kube/agones/rareicon/manifests/README.md.
Discuss on the forum
Questions, fixes and notes on this page live in the KBVE forum.