Server.json file

To use the Multiplay allocation system, you must enable a method to dynamically specify the file within your server ID directory that contains the allocation UUID supplied by your matchmaker along with other configuration variables. This file is the server.json file.

At a minimum, the server.json file must include the allocation UUID.

Copy
{
  "AllocationUUID": "$$allocated_uuid$$"
}

The server.json file exists within each server instance’s server ID directory relative to the game server binaryClosedThe executable that runs on a machine and hosts a game server session.. It contains dynamic information about the game server instance, such as the allocation UUID supplied by your matchmaker, the session authentication key, the connection IP address, and the connection port. Your build can consume variables from the build configuration or the launch parameters. See Configuration variables.

Copy
{
    "AllocationUUID": "$$allocated_uuid$$",
    "SessionAuth": "$$session_auth$$",
    "ConnectionIP": "$$ip$$",
    "ConnectionPort": "$$port$$"
}

The allocation UUID variable changes with each session, so you’ll need to monitor it for changes. To detect changes within the server.json file, you can set up an event trigger that detects file changes or a process to check the file for changes at a regular interval. It’s best practice to use an event trigger because the interval check causes unnecessary resource usage. See Monitor allocation UUID changes.

Monitor allocation UUID changes

Each game server instance must detect its allocation UUID by monitoring the value of the $$allocation_uuid$$ configuration variable in the server.json file.

Detect an allocation

The $$allocation_uuid$$ variable value changes each time you allocate or deallocate the server instance. Each game server build should monitor the server.json file to detect its allocation status and its allocation UUID.

Note: The server start and server stop actions do not impact the allocation status of the server instance or the allocation UUID.

Detect configuration variable values

Each game server build should monitor the server.json file for configuration variable changes. For example, when you allocate a server instance, the IP address, port number, and game mode might contain different values from the previous allocation. See Valid configuration variables for a full list of valid variables.

The recommended way to monitor changes to the server.json file on Linux is to use inotify to detect CLOSE_WRITE events. For an example of what a CLOSE_WRITE event looks like, see the following inotify log sample.

Copy
MODIFY server.json
OPEN server.json
OPEN server.json
CLOSE_NOWRITE,CLOSE server.json
MODIFY server.json
CLOSE_WRITE,CLOSE server.json
OPEN server.json
ACCESS server.json
server,CLOSE server.json