Skip to main content

Introduction to external dedicated game server management integration with Session Override

Last updated on September 9, 2024
info
  • Extend is in Open Beta for AGS Private Cloud Clients! This means that the Extend add-on is available for you to try in your development environment. You can submit your feedback via our Extend Open Beta feedback form.
  • Session Override is still in the alpha release. Please expect possible issues or bugs to occur during integration.

Introduction

Using AccelByte Game Services (AGS) allows you to integrate your game with your preferred external or third-party dedicated game server management tool. The AGS Session Service will request a dedicated server when the minimum number of players (in the session template config) have already joined the session.

Normal dedicated game server request flow with AMS

AGS allows you to override the default session behavior using the Extend Override. Instead of requesting a dedicated game server (DS) to AMS, the session service will request a DS from the external provider you configure in the Session Override app.

Custom dedicated game server request flow with external DS Management

This article walks you through how to modify the Extend Override app template for session function to integrate with external dedicated game server Management. This article aims to provide you with an overview of session override and an understanding of:

  • Configuring custom dedicated game server source inside the session template configuration in the AGS Admin Portal.
  • Creating a gRPC server to override session service functionality when requesting a dedicated game server.
note
  • Currently, this integration only supports Google Cloud Platform. We are working on adding more supported integrations, such as AWS Gamelift Fleet Commander. If you have a specific dedicated game server management tool or other setups you would like for AGS to support, you can submit a request through our Extend Open Beta feedback form.
  • Check out AGS's dedicated server management tool called AccelByte Multiplayer Server (AMS). AMS is a dynamic dedicated game server manager that enables you to serve dedicated game servers as close to your players as possible.

Prerequisites

Contract functions

The following are the functions in the contract:

service SessionDsm{
rpc CreateGameSession(RequestCreateGameSession) returns (ResponseCreateGameSession);
rpc TerminateGameSession(RequestTerminateGameSession) returns (ResponseTerminateGameSession);
}

CreateGameSession

CreateGameSession is called when the client or matchmaking creates a game session that requests a dedicated game server from the DS management provider.

In the app template, the following function can be found in pkg/client/gcpvm/client.go.

func (s *SessionDSM) CreateGameSession(ctx context.Context, req *sessiondsm.RequestCreateGameSession) (*sessiondsm.ResponseCreateGameSession, error) {
...
}

TerminateGameSession

TerminateGameSession is called when the game session is deleted.

In the app template, the following function can be found in pkg/client/gcpvm/client.go.

func (s *SessionDSM) TerminateGameSession(ctx context.Context, req *sessiondsm.RequestTerminateGameSession) (*sessiondsm.ResponseTerminateGameSession, error) {
...
}

Dedicated game server logic

It is essential to keep the game session lifecycle in sync with the dedicated game server (DS) status. This prevents the game session from hanging (or still being active) when the dedicated game server has already been removed or shut down. We recommend that the DS delete the associated game session when it shuts down by calling the delete game session endpoint. See also the SDK function.

Set up, run, and test the Extend App

For sample purposes, a Google Cloud (GCP) virtual machine is used in this configuration as the external place to deploy the dedicated game server.

Clone the app template

git clone https://github.com/AccelByte/session-dsm-grpc-plugin-go.git

Set up the Google Cloud Platform

  1. Log in to the Google Cloud Platform (GCP)

    gcloud auth login
  2. Create your service-key-account.

    gcloud iam service-accounts keys create test.json --iam-account=xxxx@xxxx.iam.gserviceaccount.com
  3. Allow the firewall IP address and port in the Virtual Private Cloud (VPC) for traffic in GCP.

  4. In GCP, create a repository for the sample game DS docker image (artifact). Add the tag and push the DS to the docker repository. Example command:

    docker tag sampleds asia-southeast1-docker.pkg.dev/xxxx/xxxx/sampleds
    docker push asia-southeast1-docker.pkg.dev/xxxx/xxxx/sampleds
info
  • To avoid issues during the integration, we recommend naming the instance in GCP in lowercase and not exceeding more than 62 characters.
  • See Google's documentation on configuring authentication to Artifact Registry for Docker.

Configure the app and session template

  1. Set up the GCP credentials. The credentials should be saved in a JSON file and used to call GCP. Iin the code snippet, it is named service-account-key.json.

    important

    Roles that should be allowed are Compute Admin, Artifact registry reader, artifact registry writer, and service account user.

  2. Set up the environment variable in the .env file. You can find the .env.template in the app template repository.

      AB_BASE_URL=https://test.accelbyte.io     # Base URL of AGS environment
    AB_CLIENT_ID='xxxxxxxxxx' # Client ID from the Prerequisites section
    AB_CLIENT_SECRET='xxxxxxxxxx' # Client Secret from the Prerequisites section
    PLUGIN_GRPC_SERVER_AUTH_ENABLED=true # Enable or disable access token validation

    GCP_PROJECT_ID=xxxxx-xxxx # GCP Project ID
    GCP_NETWORK=public # GCP Network type
    GCP_MACHINE_TYPE=e2-micro # GCP instance type
    GCP_REPOSITORY=asia-southeast1-docker.pkg.dev/xxxx/gcpvm #GCP Repository
    GCP_RETRY=3 # GCP Retry to get instance
    GCP_WAIT_GET_IP=1 # GCP wait time to get the instance IP in seconds
  3. Run your app (gRPC) server locally or deploy it to AGS Extend (AccelByte hosted).

  4. Run your gRPC server locally. Follow the Test with AGS steps in the Get started with session customization article.

  5. Deploy your app to AGS Extend. Follow the Deploy in AGS steps in the Get started with session customization article.

  6. Set up the session template configuration in your namespace and set the Server configuration to Custom. If you run your app locally or deploy it to your own server or cloud, fill in the Custom URL with your gRPC app public URL. If you deploy the App to AGS Extend, select the AccelByte Hosted” option and choose your Session Override App.

    Image shows session template configuration to select a custom DS app

  7. Test the Session Override app by creating a game session using the session template that you configured using Custom Server. When the minimum number of players join the session, it will request and spawn a dedicated game server in the GCP.

    Image shows gcp console sample