AMS ローカルサーバーをテスト実行する - AccelByte マルチプレイヤーサーバー (AMS) による専用サーバー - (Unity モジュール)
About
For testing your AccelByte Multiplayer Servers (AMS) server locally, AccelByte has provided a simulator called AMS Simulator. This simulator simulates the dedicated server (DS) management and monitoring processes that are done by the Watchdog of AMS. With this AMS Simulator, you are going to validate the AMS implementation without uploading the server build to AMS.
Package Windows dedicated server
To run the game server, you need to build the project targeted for the Dedicated Server platform. Here, you will see how to package a Windows server build to test the server locally.
Open Byte Wars in Unity.
Go to File > Build Settings. Choose Dedicated Server as the platform and click the Switch Platform button.
Enable the Development Build to be able to see the server logs and click Build.
Choose a folder to save the package build and click Select folder.
Wait for your server to finish packaging.
Test run the dedicated server locally
This section will test your packaged game server locally to check whether it is able to handle the state changes within the lifecycle of AMS.
Log in to the AGS Admin Portal and go to your game namespace dashboard.
Go to AccelByte Multiplayer Server > Download Resource. Locate and download the AMS Simulator for Windows. The amssim.exe file should be downloaded.
Before you run the AMS Simulator, you need to set up a new IAM client for the simulator named ByteWars-AMSSim. To create it, you can follow the same steps when you set up the server and AMS CLI IAM, but this time you need to use the configuration below.
- AGS Shared Cloud
- AGS Private Cloud
When creating the AMS Simulator IAM client, choose the Create from Template option for the Create Options field. Then, choose the Dedicated Server Tools option for the Select Template field. This IAM client template has the necessary permissions for using AMS Simulator.
After creating the AMS Simulator IAM client, add the permission below.
Resource Permission NAMESPACE:{namespace}:AMS:LOCALDS Create After downloading AMS Simulator and creating the IAM client, open Windows PowerShell and run the AMS Simulator executable using the following command to generate a config file:
.\amssim.exe generate-config
You will be able to see the
config.json
in the same path as the AMS Simulator executable. Open the file using a text editor and fill out the configuration with the information below. Replace theClientID
and theClientSecret
with the information of the ByteWars-AMSSim IAM client you created. Also, replace other placeholder values based on your game namespace and AGS environment.- AGS Shared Cloud
- AGS Private Cloud
{
"WatchdogPort": 5555,
"AGSEnvironmentURL": "<game_namespace_id>.prod.gamingservices.accelbyte.io",
"AGSNamespace": "<game_namespace_id>",
"IAM": {
"ClientID": "<ams_sim_iam_client_id>",
"ClientSecret": "<ams_sim_iam_client_secret>"
},
"LocalDSHost": "127.0.0.1",
"LocalDSPort": 7777,
"ClaimKeys": [],
"ServerName": "Your Local Server Name"
}{
"WatchdogPort": 5555,
"AGSEnvironmentURL": "<studio_name>.accelbyte.io",
"AGSNamespace": "<game_namespace_id>",
"IAM": {
"ClientID": "<ams_sim_iam_client_id>",
"ClientSecret": "<ams_sim_iam_client_secret>"
},
"LocalDSHost": "127.0.0.1",
"LocalDSPort": 7777,
"ClaimKeys": [],
"ServerName": "Your Local Server Name"
}備考- WatchdogPort is the port the app is going to use to connect to your dedicated server.
- AGSEnvironmentURL is the URL of the environment you want to register your local dedicated server to, without
http://
. - IAM is the
ClientID
andClientSecret
that were used to authenticate your AMS Simulator that you created in previous steps. - LocalDSHost and LocalDSPort are the IP and port, respectively, of the machine that runs the local dedicated server, so your play tester knows where to connect.
- ClaimKeys provides the list of claim keys that the session service uses to claim your local dedicated server. By default, the
ServerName
is registered as one of the claim keys. - ServerName is the name you want to call your local dedicated server. By default, it is registered as one of the claim keys and automatically generated using your computer name, which you can change as preferred.
ヒント- To find your game namespace ID, go to your Admin Portal and navigate to the Namespace page where your game namespaces are listed. Then, locate your game namespace under the GAMES section and click on the gear icon. On the new page, locate the Namespace ID property and there you can find your game namespace ID value.
Once the configuration is complete, run the AMS Simulator executable.
.\amssim.exe run
Here is the output of AMS Simulator. Notice that it provides an example ID format for your local dedicated server. This example is
ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
. Copy it, as you will need it in the next step.AMS simulator url ws://0.0.0.0:5555/watchdog
AMS simulator session id: 01hfaxxvfqhe9gkk2zesfx0b66.
AMS simulator session log path: session\01hfaxxvfqhe9gkk2zesfx0b66.log
Ready to accept local DS
Start the local DS with a valid DS ID that conforms to uuid standards
An example that can be copied and pasted is:
ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
==================================Command list=================================================
help show the command list again
info show AMS simulator info
ds
status show status of the ds
ready explicitly set ds into ready state.
claim claim the ds for a game session.
drain drain the ds
exit, quit exit ams simulator
=============================================================================================Run the game server executable using the commands below in Windows PowerShell. Notice that it uses the
ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
from the previous step as its local dedicated server ID. Also, adjust the path to point to theByteWars.exe
of your server build..\ByteWars.exe -log -OverrideSDKConfig "{'DsId': 'ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a'}" -watchdog_url="ws://localhost:5555/watchdog"
備考- -log will show game server's log.
- -OverrideSDKConfig is required to launch the local AMS dedicated server.
- -dsid is the dedicated server identification that will be used by the game server to initialize AMS configuration. You can use the example ID given by AMS Simulator. This example is
ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
. Note that this launch parameter will be filled in automatically on the AMS side when this dedicated server is launched in AMS. - -watchdog_url is the URL and the port that will be used to connect the game server to AMS. This example uses
ws://localhost:5555/watchdog
as the value as this is the default IP and port for AMS Simulator. You can change the configuration for AMS Simulator inconfig.json
. Note that this launch parameter will be filled automatically on the AMS side when the dedicated server is launched in AMS.
Once your game server runs, a "DS Connected" message will appear in your AMS Simulator Windows PowerShell tab to notify you that your local dedicated server has connected to AMS.
amssim> DS Connected
Check the dedicated server status using AMS Simulator by executing
ds status
. If the game server successfully registers, it will display the log below. Notice that theDS State
has changed toReady
.ds status
AMS Simulator will show the following log:
amssim> ds status
ID: xxxxx
Connected at: 2023-XX-XX 10:00:00
Last Heartbeat: 2023-XX-XX 10:00:00
DS State: Ready備考You can also check the local dedicated sever status from the Admin Portal by navigating to the side bar menu of the dashboard and selecting AccelByte Multiplayer Server > Local Server.
You can also use the command below to simulate a game session claiming a dedicated server. Notice the
DS State
now has changed toInSession
.ds claim
AMS Simulator will show the following log:
amssim> ds status
ID: xxxxx
Connected at: 2023-XX-XX 10:00:00
Last Heartbeat: 2023-XX-XX 10:00:00
DS State: InSessionYou can also check if the game server is able to handle a drain state by executing
ds drain
. If you see the log lines below, your server successfully handles drain states. Notice that theDS State
has changed toDraining
.ds drain
AMS Simulator will show the following log:
amssim> ds status
no connected dedicated serverTo quit AMS Simulator, execute the following command:
quit