Server Browser
This SDK is an optional starter kit for Unity users, which can be extended and customized later.
π‘ Features
Gain access to prebuilt automated features by installing our SDK:
Complete Examples
Lifecycle Management
Capacity Management
Filter Query Compiler
Type Definitions (C#)
Local Dev Testing
Cross-Platform
Easy to Customize
Automated Retry
βοΈ Preparation
This plugin has been tested, and supports Unity versions 2021.3.0f1+, including Unity 6 LTS.
This plugin is provided 100% free of charge, under Terms and Conditions of Free Tier.
Requirements
Install a Git Client (for example git-scm)
A git client is needed for Unity to download and install our Unity package automatically. You will not need to use git directly once it's installed.
Installation
Open your Unity Project,
Select
Window > Package Management > Package Manager,Click the β icon and select
Add package from git URL...,Input the URL of our SDK when prompted:
Click
Addand wait until installation is completed.
Import Samples
This package includes multiple samples, intended to be used individually (do not combine samples).
Verified Sources
This is the only official distribution channel for this SDK, do not trust unverified sources!
Update Package
Navigate to Edgegap SDK in Unity Package Manager and click Update .
Imported Samples are not updated automatically! Back up any custom property values, delete the sample scripts used in your scene currently and re-import samples.
Some releases may contain breaking changes. This will be indicated by a new MAJOR version.
Updating to v3
This update includes many new Server Browser utilities and examples, improves matchmaking error handling, and more. See Release Notes for a complete list.
Unity SDK update v3 includes a few breaking changes. Please re-test your integration carefully.
π Getting Started
This guide assumes basic knowledge of Server Browser concepts and a running Server Browser.
We strongly recommend importing our Auto-Assign Example to follow along code as you read this document. You can do so in Unity Package Manager > Edgegap SDK > Samples .
Overview
Our SDK utilizes heavily Dependency Injection and Observer programming patterns.
This package integrates both Server Browser and Matchmaking, which can be used together or separately. You may freely reuse any scripts for your own customized forks and integrations.
This package includes:
Runtime Files - will be compiled and bundled with your client and server builds:
Service-Specific Utilities:
Server Agent - a complete server integration to reuse/extend.
Client Agent - a complete client integration to reuse/extend.
API functions - endpoint definitions, error handling, and logging automations.
Filter Compiler - strongly typed utilities for building filter queries.
Service-Specific DTOs - typed data containers for Server Browser API.
Shared Utilities - logging, HTTP, ping, observables, etc...
Shared DTOs - used by multiple Edgegap services to pass data around.
Sample Files - bundled and compiled ONLY if imported in your project:
Auto-Assign - example handlers with auto-assigned reservations,
Custom Search - example handlers with manual instance choice.
Server Agent
Server Lifecycle and Capacity management are performed by Server Agent.
Once instantiated, agent's parent Monobehaviour (handler) must initialize the agent and provide:
onMonitorUpdatecallback - observe service health changes,onInstanceUpdatecallback - observe and react to instance and slot changes,onConfirmationsUpdatecallback - observe and react to federated authentication.
Once initialized, this agent will automatically provide validations and hook up logging observers, finishing with a single call to the monitoring API endpoint to indicate service health.
Agent's handler is expected to take control and call agent functions from this point:
DiscoverInstanceto create initial Server Instance and Slots and initiate heartbeat,DeleteInstanceonce the match concludes / to prevent new players from joining,ConfirmReservationwhen players join, to verify their identity and slot assignment,UpdateSlotto update slot capacity (on player joined/abandoned) or modify metadata,UpdateInstanceto modify instance metadata,Statusto verify Server Browser service health.
Confirmations and Slot/Instance Updates are queued and performed in batches by default (Heartbeat Mode) to maximize scalability. To iterate quicker during dev testing, use Greedy Mode.
When updating metadata, all indices must be defined. To unset non-indexed keys, simply omit them.
The agent automatically maintains a heartbeat to keep the server discoverable while running. If the agent can't reach your server browser for several consecutive heartbeats (configurable):
less than maximum - instance will be automatically re-discovered,
more than maximum - instance will be automatically deleted.
When a new player connection is established, player is expected to send their reservation ID (third party player ID) to the game server using your netcode, to perform reservation confirmation.
Once onConfirmationsUpdate triggers, handler must perform additional actions:
call
UpdateSlotto reduce available seats for any slots with confirmed reservations,accept or deny connection using netcode-specific methods.
When a player abandons game, handler is expected to increase available seats for this slot.
Allow a short time period for players to reconnect before abandoning in case of unexpected crashes.
Client Agent
Searching for instances, pagination, filtering, and reservations are performed by Client Agent.
Once instantiated, agent's parent Monobehaviour (handler) must initialize the agent and provide:
onMonitorUpdatecallback - observe service health changes,onInstancesUpdatecallback - observe and react to instance list changes.
Once initialized, this agent will automatically provide validations and hook up logging observers, finishing with a single call to the monitoring API endpoint to indicate service health.
Agent's handler is expected to take control and call agent functions from this point:
ReserveSeatsto create a capacity reservation for a particular instance/slot or auto-assign,ListInstancesto list instances with a specific filter, ordering, cursor, and page size,GetNextPageto fetch more instances with the current parameters (filters, etc),RefreshListto clear cache and reload first page, or refresh with a specific cursor,GetInstanceDetailsto fetch instance metadata and slots information for a specific instance,Statusto verify Server Browser service health.
When a new player connection is established, player is expected to send their reservation ID (third party player ID) to the game server using your netcode, to perform reservation confirmation.
Save connection details in client or game backend to reconnect in case of an unexpected crash.
π§ͺ Samples
Get started with samples including a complete functioning integration for both server and client.
Auto-Assign
Utilizes auto-assigned reservations, with client specifying only policy name. Server browser chooses an instance matching policy filter and slot with sufficient seats automatically.
Custom Search
Includes a full implementation demonstrating how to search instances and slots, hook up UI elements, and let player choose where they wish to reserve capacity manually.
βοΈ Customization
This SDK is meant to be extended and modified, though some modifications may be risky:
β Handler - safely hook up UI observers and perform minor additions or modifications,
β οΈ Agent - modify lifecycle and capacity management at your own risk,
β οΈ API - write your own integration from scratch, using cherry-picked utilities.
Handlers may observe any events emitted by Server and Client agents as described below.
Make sure to get familiar with Server Browser In-Depth concepts before making customizations.
If you need help, please reach out to us over Discord. For live games support see our ticketing system.
Server Events
Server Agent emits events (actions) for parent handler to observe and consume.
Read event payloads by accessing .Current state of any observable. π΄ Error events contain full error message delimited by a newline character after the main event message.
Preview events emitted by observable Monitor :
π’ Update
healthy
All systems OK.
π’ Update
unhealthy
Unexpected issue.
π΄ Error
get monitor failed
Misconfiguration or unexpected issue.
π‘ Warn
request timeout clamped to heartbeat [{timeout}]
Prevents race conditions.
Preview events (actions) emitted by observable Instance:
π’ Update
discovered
Instance Discovery completed OK. May be triggered if instance lost connection due to temporary condition and re-discovered.
π΄ Error
discovery duplicate
Instance with this Request ID is already discovered.
π΄ Error
discovery failed
Unexpected issue with discovery.
π΅ Notify
heartbeat ok
Heartbeat completed OK.
π‘ Warn
heartbeat failed [{consecutive}/{maximum}]
Heartbeat failed, server couldn't reach Server Browser.
π΅ Notify
instance update enqueued
Enqueued instance update for next batch (heartbeat/greedy).
π’ Update
instance updated
Instance metadata updated OK.
π΄ Error
instance update failed, enqueuing for retry
Instance update failed, possibly due to rate limiting or error.
π’ Update
instance deleted
Instance is no longer discoverable by players.
π’ Update
instance delete failed (not found)
Instance may have expired due to too many missed heartbeats.
π΄ Error
instance delete failed
Failed to delete Instance, possibly due to rate limiting or error.
π΅ Notify
slot update enqueued [{slot}]
Enqueued slot update for next batch (heartbeat/greedy).
π’ Update
slot updated [{slot}]
Slot seats capacity and/or metadata updated OK.
π‘ Warn
agent throttled concurrent slot update
Prevented attempt at concurrent update (race condition).
π΄ Error
slot update failed (not found) [{slot}]
Slot with this name is not defined for this Instance yet.
π΄ Error
slot update failed (not enough seats) [{slot}]
Slot update tried to reduce available seats below zero.
π΄ Error
slot update failed, enqueuing for retry [{slot}]
Slot update failed, possibly due to rate limiting or error.
Preview events (actions) emitted by observable Confirmations:
π΅ Notify
enqueued [{player}]
Enqueued confirmation for next batch (heartbeat/greedy).
π‘ Warn
duplicate [{player}]
Prevented attempt at duplicated confirmation (already queued).
π’ Update
confirmed
Confirmed reservations for individual slots, includes also expired and unknown player IDs for handler to resolve (accept/kick).
π΄ Error
failed
Unexpected issue with confirmations. Check service status.
Client Events
Client Agent emits events (actions) for parent handler to observe and consume.
Read event payloads by accessing .Current state of any observable. π΄ Error events contain full error message delimited by a newline character after the main event message.
Preview events emitted by observable Monitor :
π’ Update
healthy
All systems OK.
π’ Update
unhealthy
Unexpected issue.
π΄ Error
get monitor failed
Misconfiguration or unexpected issue.
Preview events emitted by observable Instances:
π΅ Notify
seats reserved
Seat reservation OK.
π΄ Error
seats reservation failed (not found)
Auto-Assign - policy name not found (deleted or inactive). Custom Search - instance or slot not found.
π΄ Error
seats reservation failed (reached capacity)
Auto-Assign - policy reached maximum capacity. Custom Search - slot reached maximum capacity.
π΄ Error
seats reservation failed
Seat reservation failed, possibly invalid policy, request ID, or slot ID.
π’ Update
instance list retrieved
Fetched list of instances OK.
π’ Update
instance list next page retrieved
Fetched next page of instances OK.
π΄ Error
instance list last page reached
Failed to fetch next page, try refreshing or changing filters.
π΄ Error
instance list next page retrieval failed
Failed to fetch next page, possibly due to an invalid cursor.
π’ Update
instance details retrieved
Fetched details of a listed instance OK.
π’ Update
instance not cached, prepending
Fetched details of instance outside current list.
π΄ Error
instance details retrieval failed
Failed to fetch details, possibly due to invalid request ID.
Last updated
Was this helpful?

