Skip to main content

SDK Quickstart

Integrate your dedicated server with GameFlow in a handful of steps. Pick your language once; the selection follows you across every step and across the rest of the docs.

The flow is the same everywhere: connect → ready → track players → shut down. Health reporting starts on its own once you call ready(); you never ping anything yourself.

1. Install​

Add the package via the Unity Package Manager (Window → Package Manager → + → Add package from git URL):

https://github.com/GameFlowGG/gameflow-gameserver-sdk.git?path=/sdk/unity/Packages/gg.gameflow.gameserver#sdk/unity/v0.1.0

Requires Unity 2022.3+ with Api Compatibility Level = .NET Standard 2.1. A Dedicated Server build is recommended for production.

2. Connect and signal readiness​

Connect on startup, start listening on the assigned port, then call ready() only when your server can actually accept connections. Until then the platform will not send players to it.

var runner = GameFlowRunner.Create();
var gf = new GameFlowClient(new GameFlowOptions {
Logger = new UnityDebugLogger(),
Dispatcher = runner.Dispatcher,
});
runner.Bind(gf);

await gf.Start(); // connects (with retries) or falls back to local mode
// start listening on your transport, then:
await gf.Ready(); // health reporting starts automatically

The GameFlowRunner is a MonoBehaviour that delivers callbacks on Unity's main thread. Headless code can skip it and use GameFlowClient directly.

3. Track players​

Register a session when a player joins and unregister it when they leave. Use any stable unique id (session id, account id).

This matters beyond dashboards: GameFlow shuts down servers that report zero players past your organization's idle timeout, so a server that never reports players will be reaped.

try {
await gf.Players.Connect(sessionId);
} catch (ServerFullException e) {
Kick(sessionId, $"server full (capacity {e.Capacity})");
}
await gf.Players.Disconnect(sessionId);

var n = gf.Players.Count; // synchronous reads

4. Use the launch payload (optional)​

Servers can be launched with an opaque payload (match config, team rosters, anything). The SDK treats it as a string, so parse it however you produced it.

var payload = await gf.Payload(); // string (null when none)

gf.OnPayloadChange(next => {
// fires when the platform assigns this server to a new match
});

5. Shut down cleanly​

When a server is stopped, the platform sends SIGTERM and force-kills the container about 45 seconds later. Drain and call shutdown() well within that budget. Also call it yourself when a match ends and the server is done.

await gf.Shutdown(); // when the match ends; idempotent

The GameFlowRunner also sends a clean shutdown automatically on application quit.

6. Ship it​

Package your server with a Dockerfile at the build root (run as UID 1000, expose your port) and upload it through the GameFlow dashboard or CLI. See Creating a Game.

Before you upload, test everything on your machine first; the same binary runs unchanged off-platform. See Local development.