# Configuration

## Installing The Plugin

1. Open the **Epic Games Launcher**, go to your **Fab Library** and search for "Kronos Matchmaking".
2. Press the **Install To Engine** button.
3. Select the desired engine version and install the plugin.

## Enabling the Plugin

Once the plugin is installed, go to **Edit -> Plugins** and under the *"Online"* category you should be able to see *"Kronos Matchmaking"*. Please make sure that the plugin is enabled!

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FVVZCf3HboZap5m9tNyLo%2FPluginEnable.jpg?alt=media&#x26;token=787176ad-469c-4462-a2b1-8a94e0d22582" alt=""><figcaption></figcaption></figure>

If you plan on using **Kronos from C++** don't forget to list it in your **build dependencies**. The build file is located in the *"Source"* folder of your project.

```csharp
// Include Kronos as a dependency.
PrivateDependencyModuleNames.Add("Kronos");

// Additional includes you may need when extending certain Kronos classes.
// The "CoreOnline" module is only needed from Unreal Engine 5 onwards.
PrivateDependencyModuleNames.AddRange(new string[] { "CoreOnline", "OnlineSubsystem", "OnlineSubsystemUtils", "Lobby", "UMG" });
```

## Project Configuration

### 1. Configuring the Online Subsystem

Kronos is built on the **Online Subsystem (OSS) framework** of Unreal Engine. Platforms such as **Steam and EOS** have their own Online Subsystem implementation in the engine by default. You just need to configure which OSS should be loaded by the engine. Kronos will do all matchmaking related features through the active OSS, so if you have it configured for Steam, then sessions (online rooms) will be created and advertised on the Steam servers.

{% tabs %}
{% tab title="Null Subsystem" %}
The **Null Online Subsystem** is an IP based subsystem that is meant to be used for testing purposes. It is only capable of handling sessions on the local network (LAN). In general you will only use this while testing in the editor. To configure this Online Subsystem, add the following settings to your project's `DefaultEngine.ini` file:

{% code fullWidth="false" %}

```ini
; The Online Subsystem to be used by the engine.
[OnlineSubsystem]
DefaultPlatformService=Null

; Specific configuration of the Null Online Subsystem.
[OnlineSubsystemNull]
bEnabled=True
bAutoLoginAtStartup=True

; The net drivers to be used by the game.
; GameNetDriver: Used by regular game connections (server-client).
; BeaconNetDriver: Used by the party and reservation systems of Kronos.
[/Script/Engine.GameEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="BeaconNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")

; The net drivers to be used by the editor.
; Only ever used during PIE so just use the IpNetDriver.
[/Script/UnrealEd.EditorEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="BeaconNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")

; Specific configuration of the Ip Net Driver.
[/Script/OnlineSubsystemUtils.IpNetDriver]
ConnectionTimeout=60.0
InitialConnectTimeout=120.0
```

{% endcode %}
{% endtab %}

{% tab title="Steam Subsystem" %}
The **Steam Online Subsystem** interfaces with the Steam platform. Use [**Steam Sockets**](https://horizongames.gitbook.io/kronos-matchmaking/advanced/steam-sockets) as your network driver. To configure this Online Subsystem, add the following settings to your project's `DefaultEngine.ini` file:

```ini
; The Online Subsystem to be used by the engine.
[OnlineSubsystem]
DefaultPlatformService=Steam

; Specific configuration of the Steam Online Subsystem.
[OnlineSubsystemSteam]
bEnabled=True
SteamDevAppId=480
GameServerQueryPort=27015
bInitServerOnClient=False
bAllowP2PPacketRelay=True
P2PConnectionTimeout=90
bRelaunchInSteam=False

; The net drivers to be used by the game.
; GameNetDriver: Used by regular game connections (server-client).
; BeaconNetDriver: Used by the party and reservation systems of Kronos.
[/Script/Engine.GameEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/SteamSockets.SteamSocketsNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="BeaconNetDriver",DriverClassName="/Script/SteamSockets.SteamSocketsNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")

; The net drivers to be used by the editor.
; Only ever used during PIE so just use the IpNetDriver.
[/Script/UnrealEd.EditorEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="BeaconNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")

; Specific configuration of the Steam Net Driver.
[/Script/SteamSockets.SteamSocketsNetDriver]
ConnectionTimeout=60.0
InitialConnectTimeout=120.0
```

{% endtab %}

{% tab title="EOS Subsystem" %}
The **EOS Online Subsystem** interfaces with the EOS platform. To get things working with EOS you'll first have to register and configure a product in the **EOS Developer Portal** and then configure the Online Subsystem to use your product. For the exact steps required please refer to the **Setup section** of the official documentation: [**Online Subsystem EOS**](https://docs.unrealengine.com/en-US/online-subsystem-eos-plugin-in-unreal-engine/)

```ini
; The Online Subsystem to be used by the engine.
[OnlineSubsystem]
DefaultPlatformService=EOS

; Specific configuration of the EOS Online Subsystem.
[OnlineSubsystemEOS]
bEnabled=True

; Further configuration of the EOS Online Subsystem.
; Your Artifact settings go here (see EOS documentation).
; This can be edited from within the editor! Do not modify directly.
[/Script/OnlineSubsystemEOS.EOSSettings]

; The net drivers to be used by the game.
; GameNetDriver: Used by regular game connections (server-client).
; BeaconNetDriver: Used by the party and reservation systems of Kronos.
[/Script/Engine.GameEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemEOS.NetDriverEOS",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="BeaconNetDriver",DriverClassName="/Script/OnlineSubsystemEOS.NetDriverEOS",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")

; The net drivers to be used by the editor.
; Only ever used during PIE so just use the IpNetDriver.
[/Script/UnrealEd.EditorEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="BeaconNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")

; Specific configuration of the EOS Net Driver.
[/Script/OnlineSubsystemEOS.NetDriverEOS]
ConnectionTimeout=60.0
InitialConnectTimeout=120.0
```

{% endtab %}
{% endtabs %}

After configuring the Online Subsystem, please go to **Edit -> Plugins** and make sure that the plugin for your Online Subsystem of choice is enabled. If you are using Steam, make sure to also enable the **Steam Sockets** plugin.

{% hint style="info" %}
**IMPORTANT:** While developing and testing the game inside the editor, you should always revert back to using the Null Online Subsystem! Please refer to the [**Testing & Debugging**](https://horizongames.gitbook.io/kronos-matchmaking/testing-and-debugging#using-the-null-subsystem) page for more information.
{% endhint %}

Note that you can configure multiple Online Subsystems and switch between them via the `DefaultPlatformService` config param. This makes development iteration faster. However, do not configure net drivers twice! The engine will automatically use the fallback net driver when the primary net driver fails to initialize (e.g. due to using a net driver that is for a different Online Subsystem).

### 2. Configuring Online Beacons

Kronos uses [**Online Beacons**](https://dev.epicgames.com/documentation/en-us/unreal-engine/using-online-beacons-in-unreal-engine) to manage parties and game reservations. `OnlineBeacons` are special actors in Unreal Engine that provide a "lightweight" way to contact a server without committing to a normal game connection. To configure the beacons used by the plugin, add the following settings to your project's `DefaultEngine.ini` file:

```ini
[/Script/Kronos.KronosPartyListener]
ListenPort=7787

[/Script/Kronos.KronosPartyClient]
BeaconConnectionInitialTimeout=60.0
BeaconConnectionTimeout=25.0

[/Script/Kronos.KronosReservationListener]
ListenPort=7788

[/Script/Kronos.KronosReservationClient]
BeaconConnectionInitialTimeout=60.0
BeaconConnectionTimeout=25.0
```

{% hint style="warning" %}
The **EOS Online Subsystem** in some previous versions of Unreal only worked with `ListenPort=15000`. If you are experiencing issues with beacon connections, try using that port instead.
{% endhint %}

### 3. Configuring the Plugin

Kronos has its own configuration page in **Edit -> Project Settings -> Kronos Matchmaking** where you can customize most features of the plugin. You can override a lot of things here, but for now please configure the following params based on your Online Subsystem of choice:

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FkACgy0sisDGvXMKLBIPZ%2FConfig.jpg?alt=media&#x26;token=42558347-df06-4fd7-b753-b8cb1ecc7d98" alt=""><figcaption></figcaption></figure>

* **Find Friend Session Supported:** Whether the `FindFriendSession` function is supported by the Online Subsystem. Steam supports this, EOS does not.
* **Find Session By Id Supported:** Whether the `FindSessionById` function is supported by the Online Subsystem. EOS supports this, Steam does not.

## Overriding the Online Session

The `OnlineSession` class in Unreal Engine is a lesser known manager type class that is part of the `GameInstance`. It's name is a bit misleading as its not related to sessions themselves, but rather acts as a manager for them. It's responsible for implementing and handling online service related events and functions. This class is the **core of the Kronos Matchmaking** plugin.

{% tabs %}
{% tab title="Blueprint Projects" %}
At this time the `OnlineSession` class in Unreal Engine can only be overridden from C++ which means Blueprint projects must use the `KronosGameInstance` class. This is basically a "dummy" class, as its only purpose is to override the online session for the project.

Please go to **Project Settings -> Maps & Modes** and set the `GameInstance` class to `KronosGameInstance`. If you already have your own game instance blueprint, you can just set its parent class to `KronosGameInstance`. That will work as well.
{% endtab %}

{% tab title="C++ Projects" %}
C++ projects can either use the `KronosGameInstance` class, or use their existing `GameInstance` classes to override the online session for the project.

Please go to **Project Settings -> Maps & Modes** and set the `GameInstance` class to either `KronosGameInstance` or override the `GetOnlineSessionClass()` function in your own game instance class as seen below.

{% code title="MyGameInstance.h" %}

```cpp
virtual TSubclassOf<UOnlineSession> GetOnlineSessionClass() override;
```

{% endcode %}

{% code title="MyGameInstance.cpp" %}

```cpp
#include "KronosOnlineSession.h"
#include "KronosConfig.h"

TSubclassOf<UOnlineSession> UMyGameInstance::GetOnlineSessionClass()
{
	return UKronosConfig::Get()->OnlineSessionClass;
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

## Configuring Shipping Builds

Important information when you are preparing the final builds of your game.

{% hint style="info" %}
**NOTE:** Information here are only relevant when packaging the project in `Shipping` build configuration.
{% endhint %}

### Using Steam In Shipping Builds

While using the `Development` or `DebugGame` configurations, the **Steam Online Subsystem** automatically creates a **"steam\_appid.txt"** somewhere inside the game's folder. This ensures that Steam can initialize correctly. However, this is not the case in `Shipping` configuration! If you are not launching the game through Steam (using your unique Steam App Id) the Steam API will fail to initialize. To fix this:

* **If you have your own unique App Id on Steam:**\
  Change the `bRelaunchInSteam` config param to True in your `DefaultEngine.ini`. This will ensure that even if you start the game's exe file directly, it will be closed and relaunched through Steam instead.
* **If you do NOT have your own unique App Id on Steam:**\
  After packaging, create a "steam\_appid.txt" file in *"\<ProjectName>/Binaries/Win64/"* folder of the game. The txt file should contain nothing but the **App Id** you wish to use, in this case the numbers: 480

### Configuration Files Are Cached

When packaging your project in `Shipping` configuration, the engine will save the configuration files to an external location outside of the game's folder. This means that if you made any changes to a config file before packaging, you may have to manually update the cached config files in the external location as well!

**On Windows**, configuration files are saved to: *"C:/Users/\<UserName>/AppData/Local/\<ProjectName>"*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://horizongames.gitbook.io/kronos-matchmaking/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
