OneLobby
Multiplayer that outlives its servers. Players host and join with a short code, peer to peer, with voice and text chat built in. Free and open source (MIT).
Current release: 0.8.2. Packages: onelobby on npm, OneLobby.Core, OneLobby.Godot, OneLobby.DataChannel on NuGet, create-onelobby for setup.
What it is
A multiplayer kit for games that should keep working after you stop paying for servers, or that never had any. Ant Arena uses it.
- No server at all
- A .NET, Unity or Node game hosts straight from the player's PC and shows a join code (
6B01-RGFE-P2B). Friends paste it and play. - Or a server anyone can run
- Web games use a tiny lobby server that only introduces players. Its address is a setting, so players or a community can run their own.
- Game data stays between players
- Peers talk over WebRTC data channels. Voice and text chat come with it.
Early software (0.x)
The API can still change between minor versions. Work goes where a shipping game needs it.
Maintained: the C# core in raw mode, OneLobby.DataChannel, the Unity package, OneLobby.Replication and the lobby server. Frozen: the JS client, the Godot glue, lockstep mode and voice. They work and keep their tests; bug reports are welcome.
Quickstart
Pick your engine. Each recipe ends with a "Done when" check you can run.
Install
npm install onelobby
Host or join
import { OneLobby } from "onelobby";
const kit = new OneLobby({ gameId: "com.you.game", netVersion: "1", lobbyServer: "wss://YOUR-SERVER/ws", mode: "raw" });
const code = new URLSearchParams(location.search).get("join"); // open the page with ?join=CODE to join
const lobby = code ? await kit.join(code) : await kit.host({ name: "My game", maxPlayers: 4 });
console.log("Join code:", lobby.code);
lobby.on("message", (from, bytes) => console.log(`peer ${from}:`, new TextDecoder().decode(bytes)));
lobby.on("peerReady", (peer) => lobby.send(peer.peerId, new TextEncoder().encode("hello!")));
Open it in two tabs (the second with ?join= plus the code) and each logs the other's hello!. YOUR-SERVER is a lobby server: run one locally and use ws://127.0.0.1:8080/ws (Run your own server), or get a free one in a few clicks.
One command
npx create-onelobby my-game --template godot-csharp --yes # a new project with the drop-in menu
npx create-onelobby --into path/to/your-project # an existing Godot C# project
Check it works
cd my-game
dotnet build MyGame.csproj
godot --headless --audio-driver Dummy --import --path . # once: registers the WebRTC extension
godot --headless --audio-driver Dummy --path . res://tests/MultiplayerTest.tscn # prints MULTIPLAYER_OK
Or by hand
dotnet add package OneLobby.Core
dotnet add package OneLobby.Godot
Needs the .NET build of Godot 4.5 or newer and the .NET 8 SDK. Full Godot C# recipe
One command
npx create-onelobby my-game --template godot-gdscript --yes # a new project with the drop-in menu
npx create-onelobby --into path/to/your-project # an existing GDScript project
Check it works
cd my-game
godot --headless --audio-driver Dummy --import --path . # once
godot --headless --audio-driver Dummy --path . -s res://tests/multiplayer.gd # prints MULTIPLAYER_OK
No .NET needed. Godot 4.4 or newer; voice chat is C# and JS only. Full GDScript recipe
One command
npx create-onelobby my-game --template unity --yes --package-from path/to/com.onelobby.unity-<version>.tgz # a new project
npx create-onelobby --into path/to/your-project --package-from path/to/com.onelobby.unity-<version>.tgz # an existing one
The Unity package is not on a registry yet: take the com.onelobby.unity-<version>.tgz tarball from a GitHub release. Desktop and mobile; not WebGL. Full Unity recipe
Install
dotnet add package OneLobby.Core
dotnet add package OneLobby.DataChannel
Host or join
using OneLobby;
using OneLobby.DataChannel;
var config = new OneLobbyConfig("com.you.game", "1", new Uri("ws://127.0.0.1:8080/ws"), SyncMode.Raw, DisplayName: "Ann");
var client = new LobbyClient(config, new DataChannelTransport());
Lobby lobby = await client.HostAsync(new LobbyOptions("Ann's game", MaxPlayers: 4, Visibility: Visibility.Public));
Console.WriteLine($"Join code: {lobby.Code}"); // a friend calls client.JoinAsync(code)
lobby.MessageReceived += (from, payload, channel) => { /* your bytes */ };
// every frame: lobby.Pump(); events fire on the calling thread
Console apps, MonoGame, bots and tests. Full .NET recipe
Using an AI coding agent?
Tell it:
Read https://github.com/ParkerTonra/onelobby/blob/main/AGENTS.md and add host/join multiplayer to my game.
Docs
The recipes from the repository, as pages. The source of truth stays on GitHub.
