# Lobby network

> A network bundle on Velocity in front of a lobby and an arena - /lobby on every server, and players kicked from a game land back in the lobby - tested with every client version the proxy serves.

The lobby network is the reference for network bundles. Velocity stands in front of two Paper servers, `lobby` and `arena`. Every player can type `/lobby`, and a player kicked from a game lands back in the lobby with a message that says why.

Source: [`examples/lobby-network`](https://github.com/minekube/minekube/tree/main/examples/lobby-network).

## What it shows

- **Rules for the proxy.** `network/Lobby.ts` imports no Java. The `Lobby` component has three messages (`AskedForLobby`, `Kicked`, `Connected`) and two Commands (`Connect`, `Tell`).
- **The proxy half.** `network/velocity.ts` default-exports `Network.make(...)` from `@minekube/network`. It registers `/lobby` with `Network.command`, turns Velocity's kick event into a message, and implements `Connect` with a connection request whose result is the `Connected` message.
- **Servers by selector.** In the dev network, Velocity finds `lobby` and `arena` by label selectors (`stage=lobby`, `game=arena`), through the registry. See [Labels and selectors](https://minekube.com/guide/networks/labels).
- **A swap on the proxy.** `lobby-network.e2e.ts` swaps the network bundle for a new revision while the client stays connected, then a backend kicks the player.
- **Every client version.** `matrix.e2e.ts` joins with the official client of each protocol version Velocity lists. Each one must land in the lobby, get `/lobby`'s answer and survive a kick, on one connection.

## Run it

From the repository:

```sh
mk server --network
mk dev examples/lobby-network
```

Join `localhost`. `bun test examples/lobby-network` runs the rules and replays `recordings/lobby-and-kick.ndjson`. `bun run test:e2e` and `bun run test:matrix` run the end-to-end tests. They need the dev network and Java 25, and the matrix downloads a few GB of clients on its first run.

## Read next

- [Network bundles](https://minekube.com/games/write/network-bundles): how a network bundle is written.
- [Run the dev network](https://minekube.com/games/local-development/dev-network): what `mk server --network` starts.
