Discover how Edgegap works

Discover how Edgegap works

/

/

Multiplayer Servers Sample

PlayFab

Multiplayer Servers Sample

Deploy to Edgegap

Published

Published

Published

Last reviewed for accuracy

Last reviewed for accuracy

Last reviewed for accuracy

PlayFab's Multiplayer Servers sample: Run it on Edgegap dedicated servers, in Unity

PlayFab's Multiplayer Servers sample: Run it on Edgegap dedicated servers, in Unity

This is PlayFab's own Unity sample for PlayFab Multiplayer Servers, from Microsoft's MpsSamples, running on Edgegap instead. Edgegap's fork keeps the same Unity server and client, removes the PlayFab Game Server SDK (GSDK), and builds and uploads the server with the Edgegap Unity plugin.

Nothing is pre-provisioned. There is no build region, standby pool or virtual machine to size: each dedicated server starts on request, near its players, and stops itself when they leave.

Edgegap's network spans 615+ Edge Cloud locations (learn more). Each server is deployed to the best available location for its players and billed only while the match runs.

Platforms: Windows desktop client (tested), Linux dedicated server. Original sample by Microsoft PlayFab, under the Apache 2.0 license.

How it works

  1. You build the Unity server and upload it as an Edgegap app version, with the Edgegap Unity plugin.

  2. A small console app, EdgegapAllocatorSample, asks Edgegap for a server near the players' IPs. It plays the part of PlayFab's RequestMultiplayerServer call and prints the server's address once it's ready.

  3. The server listens on TCP port 7777 as soon as it starts. Clients connect to the address with -server host:port.

  4. When the players leave, the server stops its own deployment, so billing stops.

On PlayFab Multiplayer Servers vs on Edgegap:

On PlayFab Multiplayer Servers (GSDK)On Edgegap
AgentListener.cs: GSDK Start, port from GetGameServerConnectionInfo, ReadyForPlayers, listen on OnServerActiveEdgegapServer.cs: listen on the fixed port 7777 at startup
UpdateConnectedPlayersNot needed. The server logs its player count
OnShutDownCallbackEdgegap sends SIGTERM; players get the same ShutdownMessage when Unity quits
Build, VM size, servers per VM, standby serversAn app version: image, 0.5 vCPU / 1 GB per server, port gameport TCP 7777
RequestMultiplayerServerPOST /v2/deployments (EdgegapAllocatorSample)
Server runs until PlayFab shuts it downThe server stops its own deployment 120 s after start if nobody joins, or 30 s after the last player leaves

No credit card required. Free tier includes the resources to deploy a real game server.

No credit card required. Free tier includes the resources to deploy a real game server.

Step-by-Step Guide

Run the Sample

1. Before you start

  • A free Edgegap account and an API token from Dashboard → User Settings → Tokens. It's organization-wide: keep it on your machine or your backend, never in a game client.

  • Unity 2021.3.45f2, with Linux Build Support and Linux Dedicated Server Build Support. Both projects use this version.

  • Docker Desktop, for the plugin's container build.

  • The .NET SDK 8 or newer, for EdgegapAllocatorSample.

  • Clone the fork. The sample lives in UnityMirror/ (UnityServer and UnityClient) and EdgegapAllocatorSample/.

Git: Unity needs a Git client (2.14.0 or newer) on your PATH to install packages from a Git URL, such as the Edgegap plugin. macOS usually has one already (Xcode Command Line Tools); on Windows, install Git.

2. Build and upload the server

Open UnityMirror/UnityServer in Unity. The Edgegap Unity plugin is already in its packages, pinned to 3.2.1. Open Tools → Edgegap Server Hosting:

  1. Sign in with Edgegap, then Build server.

  2. Containerize with Docker: image name mps-unity-mirror, image tag empty (the plugin uses the current UTC time).

  3. Optional local check: run parameters -p 7777:7777/tcp, then Deploy local container.

  4. Upload to Edgegap: application mps-unity-mirror, then Upload image and Create app version.

In the version form:

  • One port: name gameport, 7777, TCP (the sample uses Mirror's Telepathy transport).

  • 0.5 vCPU and 1 GB.

  • A max duration of 60 minutes. The server also stops itself.

  • If asked, the registry username and token from the dashboard's Container Registry page.

To build from the command line instead (CI, scripted tests), with the project closed in the Editor:

"<Unity>" -batchmode -projectPath UnityMirror/UnityServer -executeMethod EdgegapPluginBuild.BuildServer -logFile build-server.log

3. Start a server

EdgegapAllocatorSample is the Edgegap counterpart of PlayFab's MpsAllocatorSample: a .NET console app that calls the Edgegap API with HttpClient, no SDK. Give it your token, the application and the version name from step 2:

cd EdgegapAllocatorSample

export EDGEGAP_API_TOKEN="token xxxxxxxx" EDGEGAP_APP=mps-unity-mirror EDGEGAP_VERSION=<version name>

dotnet run -- deploy <your public IP>

It prints -server <host>:<port> once the server is ready. You can also pass players as latitude,longitude, several at once: Edgegap picks the best available location for the whole group.

Run dotnet run without arguments for the menu: list versions, list deployments, get one deployment, or stop one.

PlayFab's MpsAllocatorSampleEdgegapAllocatorSampleEdgegap API
RequestMultiplayerServer1: deploy a server, wait until it's ready, print host:portPOST /v2/deployments, then GET /v1/status/{request_id}
ListBuildSummaries2: list the application's versionsGET /v1/app/{app}/versions
ListMultiplayerServers3: list deploymentsGET /v1/deployments
GetMultiplayerServerDetails4: get one deploymentGET /v1/status/{request_id}
ShutdownMultiplayerServer5: stop a deploymentDELETE /v1/stop/{request_id}

Every deployment it starts is tagged edgegap-allocator-sample.

4. Connect two clients

Build UnityClient for Windows. It has no server build, so Unity's command line works as is:

"<Unity>" -batchmode -quit -projectPath UnityMirror/UnityClient -buildTarget Win64 -buildWindows64Player Builds/Client/win64/Client.exe

Then start two clients with the address from step 3:

UnityMirror/UnityClient/Builds/Client/win64/Client.exe -server <host>:<port>

Both join the same server. Without -server, the client uses the address and port set on its NetworkManager in the Inspector. Quit the clients: the server stops its deployment 30 seconds later and disappears from the Edgegap dashboard.

5. Move your own game off PlayFab Multiplayer Servers

The fork is a working reference for leaving PlayFab Multiplayer Servers: your coding agent can copy its tested files instead of writing them from scratch. Four changes move a Unity server off the GSDK:

  1. Remove the GSDK. Delete Assets/PlayFabSdk and replace AgentListener.cs with a small server script that listens on a fixed port at startup (the fork's EdgegapServer.cs keeps the same .meta, so the scene needs no edit).

  2. Stop the server yourself. Call the ARBITRIUM_DELETE_URL Edgegap gives every deployment, with ARBITRIUM_DELETE_TOKEN, when nobody joins or everyone has left. Call SelfStop() when a match ends.

  3. Start servers through the Edgegap API. Replace RequestMultiplayerServer with POST /v2/deployments, sent from your backend, with the players' IPs or coordinates.

  4. Containerize with the plugin. Build, containerize and upload with the Edgegap Unity plugin, then create an app version with your game port.

With Mirror, start the server through NetworkManager.StartServer() rather than NetworkServer.Listen, or clients get dropped as unauthenticated.

With your agent:

"Load the edgegap skill, then edgegap-unity and the skill for my netcode. Using github.com/edgegap/backend-game-sample-unity-mirror-playfab-mps (UnityMirror) as the reference, remove the PlayFab GSDK from my Unity server, make it listen on a fixed port at startup and stop its own Edgegap deployment when empty, and containerize it with the Edgegap Unity plugin."

For the whole move, by hand, see the PlayFab migration guide.

6. Add matchmaking

The sample has no matchmaker yet: you start each server with EdgegapAllocatorSample or the dashboard. To group players into these servers, pick one:

  • Keep PlayFab Matchmaking. Turn server allocation off on your queue, and let an Azure Function start an Edgegap server for each match. The PlayFab integration guide walks through it, and the SpaceEdge sample runs it end to end.

  • Use Edgegap's matchmaker. A hosted matchmaker that starts the server for each match, with no backend code. See the matchmaker documentation.

Known limits

  • No matchmaker in the sample. Servers start from EdgegapAllocatorSample on your machine, with your API token. In production, start them from your backend or a matchmaker, never from a game client.

  • Plugin 3.2.1 logs the self-stop token. Its Dockerfile runs env first, so the deployment logs show the injected variables, including ARBITRIUM_DELETE_TOKEN. Fixed in the plugin's next release (edgegap/buildtool-unity-plugin#62): update the pinned version once it ships.

  • The server doesn't check who connects. For production, pass the expected players to the server and reject the others.

  • Only the Windows client was tested. The other PlayFab samples in the fork (Unreal, telemetry, wrapping the GSDK) are unchanged from Microsoft's repository.

What was tested

Tested end to end on Edgegap on 29 October 2026, with Unity 2021.3.45f2 and the Edgegap Unity plugin 3.2.1:

  • EdgegapAllocatorSample deploy started the server in Toronto within seconds.

  • Two Windows clients connected over TCP (2 player(s) connected).

  • After they quit, the server stopped its own deployment.

  • Also run in Docker locally: same result, and docker stop sent the connected client a shutdown message before the server exited.

Frequently Asked Questions

Questions about running PlayFab's Multiplayer Servers sample on Edgegap.

Can I run PlayFab's Multiplayer Servers samples on Edgegap?

Yes. Edgegap's fork of Microsoft's MpsSamples runs the Unity Mirror sample on Edgegap dedicated servers without the GSDK. It was tested end to end in October 2026, with two clients on one server.

Do I need the PlayFab GSDK on Edgegap?

No. The server listens on a fixed port when it starts and stops its own deployment when the players leave. There is no agent to report to, no heartbeat and no ready state to set.

What replaces RequestMultiplayerServer on Edgegap?

A POST /v2/deployments call to the Edgegap API, with the players' IPs or coordinates. Edgegap starts the server at the best available location for them and returns its address. The sample's EdgegapAllocatorSample shows the call next to each MpsAllocatorSample command.

Do I need standby servers on Edgegap?

No. Each server starts on request, near its players, so there is no standby pool to size. If your game needs pre-warmed servers, Private Fleets can keep capacity running.

Clients

Learn more from clients who integrated Edgegap

31 case studies are available from studios that moved to Edgegap from another platform.

Key reasons why they chose Edgegap

Discover the impact of Edgegap's automated game server orchestration for a flawless multiplayer experience.

Cost

Pricing

Pricing

Optimize costs and performance with hybrid orchestration

Optimize costs and performance with hybrid orchestration

Optimize costs and performance with hybrid orchestration

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0261

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0261

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0261

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Your bill varies per rate and usage; which can vary per game type, player count, & more.

Your bill varies per rate and usage; which can vary per game type, player count, & more.

Model your usage with our estimate calculator ->

Model your usage with our estimate calculator ->

Edgegap's features & price: detailed comparison between Edge Cloud & Private Fleets

Edgegap's features & price: detailed comparison between Edge Cloud & Private Fleets

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.