Skip to main content
The PlayFlow SDK includes a LobbyHelloWorld.cs script that provides a simple, keyboard-driven way to test the entire lobby and matchmaking lifecycle without needing to build any UI. It’s the fastest way to see the SDK in action. This guide will walk you through setting up and using this example.

Prerequisites

Before you start, make sure you have:
  • A PlayFlow project and a client API key (prefix pfclient_), which is safe to ship in a game build. With the default none player-auth provider this key is all you need for the hello-world. If your project has a player-auth provider configured (custom JWT, PlayFab, or Steam), client-key requests must also send a valid player token — see Player Authentication.
  • A lobby config created for your project, and the manager’s default lobby config set to match it (this example uses firstLobby).
  • A matchmaking mode named 1VS1 defined on that lobby config if you want to test the matchmaking keys (M/N). A mode name that doesn’t exist in your project config means the matchmaking keys have nothing to match against. See Matchmaking for how to define modes, teams, and rules.

Setup Instructions

Follow these steps to get the example running in the Unity Editor.
1

Create a Test Scene

Start with a new, empty scene in your Unity project.
2

Add the Lobby Manager

  1. Create an empty GameObject and name it PlayFlowManager.
  2. Add the PlayFlowLobbyManagerV2 component to this GameObject.
  3. In the Inspector, paste your client API key (pfclient_...) into the corresponding field.
  4. Set the component’s default lobby config to firstLobby (or the name of the lobby config you created for your project).
3

Add the Hello World Script

  1. Create another empty GameObject and name it LobbyTester.
  2. Add the LobbyHelloWorld.cs script to this GameObject. This script is located in Packages/PlayFlow Multiplayer Unity SDK/Runtime/PlayFlow Multiplayer/Lobby/Examples/.
4

Run and Test

Press Play in the Unity Editor. Open your Console window to see the output and instructions. You can now use the keyboard shortcuts to interact with the lobby system.

How It Works

The LobbyHelloWorld.cs script performs several key actions:
  1. Initializes the PlayFlowLobbyManagerV2 with a unique player ID.
  2. Subscribes to all the major lobby events to provide real-time feedback in the console.
  3. Listens for keyboard inputs in its Update() loop to trigger lobby functions.

Keyboard Shortcuts

While the scene is running, use these keys to test the lobby functionality. Watch the Console window for detailed logs.
The shipped script also binds the U key to a “host updates another player’s state” demo. That key is intentionally left out of this table because the backend has no endpoint for one player to write another player’s state — see the warning below.

The Example Code

Below is the full code for the LobbyHelloWorld.cs example. It’s a great reference for how to call the different SDK functions and handle their success/error callbacks.
The example includes methods that call UpdateStateForPlayer(...) — the U key (UpdateOtherPlayerState), HostUpdateAnotherPlayerState, and HostAssignTeamsToAllPlayers. The backend does not support one player writing another player’s state. Every state write goes to the caller’s own verified identity (PATCH /me), so these host-authoritative writes will not take effect on the server. To manage shared state, have each player set their own state with UpdatePlayerState, or store shared/lobby-wide data in the lobby’s custom settings from the host.
When the match server is ready, always read the connection host and external port from the server details (OnMatchServerDetailsReady / GetGameServerConnectionInfo). Proxy ports are allocated per server and differ from your game’s internal listen port, so never hardcode a port like 7777 on the client.