Skip to main content
All CollectionsMultiplayer
Hosting Servers on Edgegap
Hosting Servers on Edgegap

This document explains how to utilize EdgeGap for hosting brainCloud Room and Relay servers.

Paul Winterhalder avatar
Written by Paul Winterhalder
Updated over 3 weeks ago

Requirements:

  • You should already have a dedicated room server built and dockerized

  • Your server should be functional using brainCloud's built-in hosting

Note that this is not an exhaustive Edgegap tutorial. For more information - check out https://docs.edgegap.com/docs/getting-started/integration.

1 - Set up an Application in the Edgegap Portal

First, you must set up your server on the Edgegap portal - which is called an application within Edgegap.

To do so, simply:

  • Login to Edgegap

  • Go to the Applications section

  • Click Create Application

  • Fill out the page of details regarding your app, the container image, etc.

  • Click Advanced Settings

    • Choose Seat session type

    • Set the # of session sockets required for a match

  • Then choose Create Version

  • The fill in the Port options according to how you have built your server

2 - Set up a Token to use to access Edgegap from brainCloud

  • Login to Edgegap (if you aren't already logged in)

  • Choose your team in the bottom-left corner - and then click Tokens

  • Create a new token for brainCloud - and keep it handy - or just be ready to go back to the page to retrieve it.

  • token 071e84cb-4577-4663-98c8-7a944a3ddc8e

3 - Set up the Edgegap server type in brainCloud

  • Login to the brainCloud Portal

  • Choose your app - and then navigate to App > Design > Servers > My Servers

  • Click [+ Add New Server]

    • Enter a name

    • Choose Edgegap Server for Server Type

    • Then fill in the Edgegap-specific information

      • Edgegap App Name - as entered in the Edgegap portal

      • Edgegap Version Name - enter the version to be launched

      • Edgegap API Key - this is the token retrieved in step 2. Note that brainCloud doesn't require the "token " prefix at the beginning of the token. The web UI will automatically strip it off for you.

      • Beacons - choose the regions to ping when doing geo matchmaking

    • Click [Save & Close]

4 - Connect the Edgegap server to the appropriate Lobby types

  • Login to the brainCloud Portal

  • Navigate to App > Design > Multiplayer > Lobbies

Choose a lobby that you would like to launch servers on Edgegap, and edit it to launch the new Edgegap Server type you just created.

5 - Modify your server to terminate the Edgegap deployment

Important note: When your server shuts down, it has to terminate the EdgeGap deployment, this is not done automatically and has to be implemented in your server when it wants to shut down. This is implemented by sending a DELETE web request to EdgeGap API as documented here.

When EdgeGap servers deploy, there are environment variables that are injected which provide the URL to call as well as the authorization token to provide with it to delete the deployment.

The environment variable for the deployment delete url is named ARBITRIUM_DELETE_URL and the environment variable for the authorization token is named ARBITRIUM_DELETE_TOKEN.

This is example C++ code for Unreal implementation of this call:

    FString deploymentDeleteUrl = getenv("ARBITRIUM_DELETE_URL");
FString authToken = getenv("ARBITRIUM_DELETE_TOKEN");

if (!deploymentDeleteUrl.IsEmpty()) {
UE_LOG(DedicatedServerLog, Log, TEXT("EdgeGap server shutting down sending request to delete url: %s"), *deploymentDeleteUrl);
TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetURL(deploymentDeleteUrl);
HttpRequest->SetVerb("DELETE");
HttpRequest->SetHeader("authorization", *authToken);
// HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
HttpRequest->OnProcessRequestComplete().BindUObject(this, &ADedicatedDemoGameMode::OnDeploymentDeleteResponse);

// Send the request
HttpRequest->ProcessRequest();
}

---

Your app should now be ready to use the new Lobby type and server.

When your lobby starts, brainCloud will send the connection details (IP:PORT) to your application once the EdgeGap server is deployed, then your application would connect to it.

From there - your Edgegap-based room server can send information to brainCloud just like any other Room Server -- that is, via the S2S API.

Your server will be launched with the following ENVs which can be used to establish the S2S connection.

SERVER_HOST     <-- "api.braincloudservers.com"
SERVER_PORT <-- 443
APP_ID <-- "55555"
SERVER_NAME <-- "arena2v2"
SERVER_SECRET <-- "aaaa-bbbb-cccc-ddd-eee"
LOBBY_ID <-- "55555:arena2v2:123"

Handy references for S2S:

Reach out to brainCloud support if you have further questions!

Did this answer your question?