-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding GSDK related documentation (#315)
- Loading branch information
1 parent
e57bb97
commit e3ee6df
Showing
12 changed files
with
208 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
layout: default | ||
title: GSDK integration | ||
nav_order: 5 | ||
has_children: true | ||
--- | ||
|
||
# How to run your game server on Thundernetes? | ||
|
||
Once you [install Thundernetes](quickstart/installing-thundernetes.md) (either on [kind](quickstart/installing-kind.md) or [AKS](quickstart/installing-aks.md)) and verify it's working as intended, you can prepare your game server for Thundernetes by integrating with the open source [Game Server SDK (GSDK)](https://github.com/playfab/gsdk). GSDK library is also used by [Azure PlayFab Multiplayer Servers (MPS)](https://docs.microsoft.com/gaming/playfab/features/multiplayer/servers/) service. In this way, you can easily migrate your game servers from MPS to Thundernetes and vice versa. | ||
|
||
Integrating with GSDK is required for your game server to run on Thundernetes. Integration serves two purposes: | ||
- allows your game server process to communicate its state to Thundernetes (Initializing, StandingBy, Terminated) | ||
- allows Thundernetes to allocate your game server for a game session | ||
|
||
To integrate with GSDK, follow the guide for the programming language/environment you are using. | ||
|
||
- [Unity GSDK](unity.md) | ||
- [Unreal GSDK](unreal.md) | ||
|
||
> **_NOTE_**: For experimenting with Thundernetes, you can use our [wrapper sample](../howtos/usingwrapper.md). This sample takes care of calling the GSDK for you and launching your game server as a separate process. | ||
## Run your game server on Thundernetes | ||
|
||
To run your game server on Thundernetes, you need to create a [GameServerBuild](../gameserverbuild.md). | ||
|
||
```yaml | ||
apiVersion: mps.playfab.com/v1alpha1 | ||
kind: GameServerBuild | ||
metadata: | ||
name: gameserverbuild-sample | ||
spec: | ||
titleID: "1E03" # required | ||
buildID: "85ffe8da-c82f-4035-86c5-9d2b5f42d6f6" # must be a GUID | ||
standingBy: 2 # required | ||
max: 4 # required | ||
crashesToMarkUnhealthy: 5 # optional, recommended | ||
portsToExpose: | ||
- 80 | ||
template: | ||
spec: | ||
containers: | ||
- image: <containerRegistryUrl>/<containerImage>:<tag> | ||
name: <containerName> | ||
ports: | ||
- containerPort: <portName> # your game server port | ||
protocol: <TCP or UDP> # your game server port protocol | ||
name: gameport # required field | ||
``` | ||
You can call this file `gameserverbuild.yaml`. | ||
|
||
- To configure this GameServerBuild to run on your cluster, you should run the following command: | ||
|
||
```bash | ||
kubectl apply -f /path/to/gameserverbuild.yaml | ||
``` | ||
|
||
- Running `kubectl get gsb` and `kubectl get gs` should show something like this: | ||
|
||
```bash | ||
dgkanatsios@desktopdigkanat:digkanat$ kubectl get gsb | ||
NAME STANDBY ACTIVE CRASHES HEALTH | ||
gameserverbuild-sample 2/2 0 0 Healthy | ||
dgkanatsios@desktopdigkanat:digkanat$ kubectl get gs | ||
NAME HEALTH STATE PUBLICIP PORTS SESSIONID | ||
gameserverbuild-sample-rtgnm Healthy StandingBy 172.18.0.2 80:14913 | ||
gameserverbuild-sample-spdob Healthy StandingBy 172.18.0.2 80:14208 | ||
``` | ||
|
||
Congratulations, your game server is up and running on Thundernetes! | ||
|
||
### Run your game server on Azure Kubernetes Service with Azure Container Registry | ||
|
||
As soon as you build your container image, you should publish it to a container registry. If you are using Azure Kubernetes Service, we recommend publishing your image to [Azure Container Registry](https://docs.microsoft.com/azure/container-registry/). To integrate your Azure Container Registry with your Azure Kubernetes Service cluster, check the instructions [here](https://docs.microsoft.com/azure/aks/cluster-container-registry-integration). |
3 changes: 2 additions & 1 deletion
3
docs/gameserverlifecycle.md → docs/gsdk/gameserverlifecycle.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/howtos/runlocalmultiplayeragent.md → docs/gsdk/runlocalmultiplayeragent.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
layout: default | ||
title: Unity | ||
parent: GSDK integration | ||
nav_order: 1 | ||
--- | ||
|
||
# Integrating GSDK with Unity | ||
|
||
You can find the Unity GSDK [here](https://github.com/PlayFab/gsdk/tree/main/UnityGsdk). This folder contains the Game Server SDK for the [Unity game engine](https://unity.com/). The GSDK files are in the `Assets/PlayFabSdk/MultiplayerAgent` folder. The entire GSDK is usable by class `PlayFabMultiplayerAgentAPI`. | ||
|
||
### What do I need to do in order to use the Unity GSDK in a new project? | ||
|
||
You can drag the `PlayFabSDK` folder to your Unity project or you can use the provided `unitypackage` file. After that, you need to enable the scripting directive `ENABLE_PLAYFABSERVER_API` on your Build settings, like in [this screenshot](https://user-images.githubusercontent.com/8256138/81462605-a6d7ac80-9168-11ea-9748-110ed01095c2.png). This is useful if your game server and client share the same project files. | ||
|
||
### Usage | ||
|
||
The minimum work you need to is call the `PlayFabMultiplayerAgentAPI.Start()` when your server is initializing and then call the `PlayFabMultiplayerAgentAPI.ReadyForPlayers();` when your server is ready for players to connect. | ||
|
||
```csharp | ||
StartCoroutine(ReadyForPlayers()); | ||
... | ||
} | ||
|
||
IEnumerator ReadyForPlayers() | ||
{ | ||
yield return new WaitForSeconds(.5f); | ||
PlayFabMultiplayerAgentAPI.ReadyForPlayers(); | ||
} | ||
``` | ||
|
||
To create your container image to use on Kubernetes, you should build a "Linux Dedicated Server" and then use a Dockerfile similar to the following: | ||
|
||
``` | ||
FROM ubuntu:18.04 | ||
WORKDIR /game | ||
ADD . . | ||
CMD ["/game/UnityServer.x86_64", "-nographics", "-batchmode", "-logfile"] | ||
``` | ||
|
||
### Samples | ||
|
||
For a more robust sample integrating Unity with the popular [Mirror](https://mirror-networking.com/) networking library, check the `MpsSamples` repository [here](https://github.com/PlayFab/MpsSamples/tree/main/UnityMirror). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
layout: default | ||
title: Unreal | ||
parent: GSDK integration | ||
nav_order: 2 | ||
--- | ||
|
||
# Integrating GSDK with Unreal | ||
|
||
You can find the Unreal GSDK [here](https://github.com/PlayFab/gsdk/tree/main/UnrealPlugin). This folder contains the Game Server SDK for the [Unreal game engine](https://unrealengine.com/). | ||
|
||
### What do I need to do in order to use the Unreal GSDK in a new project? | ||
|
||
The Unreal server project needs to be a network-enabled multiplayer Unreal project with a dedicated-server mode. If you don't have a project that meets these prerequisites, follow our [Unreal prerequisite](https://github.com/PlayFab/gsdk/blob/main/UnrealPlugin/ThirdPersonMPSetup.md) set up guide to set one up. Once you have a network-enabled, multiplayer game, with a dedicated server, return to this step and continue. | ||
|
||
When ready, open your network-enabled multiplayer Unreal server project, and continue to the [next step](https://github.com/PlayFab/gsdk/tree/main/UnrealPlugin), specifically to the part about [building for the cloud](https://github.com/PlayFab/gsdk/blob/main/UnrealPlugin/ThirdPersonMPCloudDeploy.md). | ||
|
||
At a minimum, you would need to call the `SetDefaultServerHostPort()` to get the port your server should listen to and `ReadyForPlayers()` method to transition your server to the StandingBy state. | ||
|
||
```cpp | ||
#if UE_SERVER | ||
UGSDKUtils::SetDefaultServerHostPort(); | ||
#endif | ||
|
||
// ... | ||
|
||
void U[YourGameInstanceClassName]::OnStart() | ||
{ | ||
UE_LOG(LogPlayFabGSDKGameInstance, Warning, TEXT("Reached onStart!")); | ||
UGSDKUtils::ReadyForPlayers(); | ||
} | ||
``` | ||
|
||
To create your container image to use on Kubernetes, you should build a "Linux Dedicated Server" and then use a Dockerfile similar to the following: | ||
|
||
``` | ||
FROM ubuntu:18.04 | ||
# Unreal refuses to run as root user, so we must create a user to run as | ||
# Docker uses root by default | ||
RUN useradd --system ue | ||
USER ue | ||
EXPOSE 7777/udp | ||
WORKDIR /server | ||
COPY --chown=ue:ue . /server | ||
USER root | ||
CMD su ue -c ./ShooterServer.sh | ||
``` | ||
|
||
### Samples | ||
|
||
Check [this guide](https://github.com/PlayFab/MpsSamples/tree/main/UnrealThirdPersonMP) on how to integrate the [Unreal Third Person template](https://docs.unrealengine.com/4.27/en-US/Resources/Templates/ThirdPerson/) with the Unreal GSDK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.