Retrieving DNS Name and Port Before the onGameSessionStart Callback

0

I am currently writing a server using the C# SDK. I would ideally like to retrieve the DNS Name and Port of the process before calling ProcessReady(), as there is some initialization I would to do with that information. Is this possible? Am I misunderstanding a part of the process?

Thanks for the help!

已提問 3 年前檢視次數 180 次
2 個答案
0
已接受的答案

Hi @REDACTEDUSER

Those are certainly possible.

For DNS name of the instance, you'd need to use EC2 metadata, see "HostName" in https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html. Here is how you can retrieve the data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html

Port, on the other hand, is under your control. The recommendation is to pass them in via command line argument when executing your game server process, e.g.

aws gamelift create-fleet --region $REGION \
--name "TestFleet" --ec2-instance-type c5.large  \
--ec2-inbound-permissions FromPort=6252,ToPort=6254,IpRange="0.0.0.0/0",Protocol=TCP FromPort=22,ToPort=22,IpRange="0.0.0.0/0",Protocol=TCP \
--build-id $BUILD_ID \
--runtime-configuration ServerProcesses="[{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6251 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6252 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6253 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6254 gameSessionLengthSeconds:10',ConcurrentExecutions=1}]"

Then, in my gamelift-test-app, I retrieve the port parameter from the CLI and use that for ProcessReady.

已回答 3 年前
0

That is exactly what I was looking for. Thank you for the help!

已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南