How to communicate with GameLift Server with Java Client
I have a Java Client I am attempting to integrate with GameLift. I am able to use it to search for Active Fleets, Search Game Sessions, Create Game Sessions and Create Player Sessions. I do not know where to go from there. What API or Java method is used to communicate with the Server. I have the example Server setup and running. The example server code is shown here: https://docs.aws.amazon.com/gamelift/latest/developerguide/realtime-script.html
The Java code I have written:
AmazonGameLift gameLift = AmazonGameLiftClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(credentials)) .withRegion("us-east-2") .build();
DescribeFleetAttributesRequest dfar = new DescribeFleetAttributesRequest(); DescribeFleetAttributesResult describeFleetResult = gameLift.describeFleetAttributes(dfar);
CreateGameSessionRequest cgsRequest = new CreateGameSessionRequest().withFleetId(describeFleetResult.getFleetAttributes().get(0).getFleetId()) .withName("Sim Game") .withMaximumPlayerSessionCount(MAX_PLAYERS);
CreateGameSessionResult cgsResult = this.gameLift.createGameSession(cgsRequest);
byte array = new byte[[PLAYER_ID_LENGTH]]; // length is bounded by PLAYER_ID_LENGTH new Random().nextBytes(array); String playerID = new String(array, Charset.forName("UTF-8"));
CreatePlayerSessionRequest cpsRequest = new CreatePlayerSessionRequest().withGameSessionId(cgsResult.getGameSession().getGameSessionId()) .withPlayerId(playerID);
CreatePlayerSessionResult cpsResult = this.gameLift.createPlayerSession(cpsRequest); ////////////////////////////////////////////////////////////////////////////////////////
I am assuming there is a way to communicate using to the Server using some call to cpsResult. My theory is to use cpsResult.getPlayerSession().marshal()
But I do not understand how to use the marshall function. void marshall(ProtocolMarshaller protocolMarshaller) I am also not sure that is even the correct function to use.
If anyone can point me in the right direction to start attempting Server communication I would be very grateful.
You should build user own communication model for you Java client and Game server. The GameLift doesn't cover that area.
There are two ways of using GameLift managed service.
One is using the game build, that you should build your own communication model into the game server application. It doesn't handle game client connection or communication. You also have to integrate your game server with GameLift agent, via GameLift server SDK, which is not support for JAVA currently. You can refer the architecture from following document : https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-architecture.html.
The other is realtime server that you linked. It support client, server communication, and GameLift integration is the server side, and you can use custom node.js script for you own game logic. To use realtime server, you should use realtime client sdk for communicating with the server script. Currently the client sdk is not support in Java environment officially. The architecture of realtime server is in following document: https://docs.aws.amazon.com/gamelift/latest/developerguide/realtime-architecture.html.
So if you want to use Java client, you should build you own communication model from the other network library or you should find or implement realtime client sdk that is unofficial.
How can I create a friends list with GameLift?asked a year ago
UE4+Gamelift client connection failsAccepted Answerasked 7 months ago
How to communicate with GameLift Server with Java Clientasked 6 months ago
How do you setup GameLift Client for Unreal Engine 4?asked 5 years ago
How to create a client authoritive player for a multiplayer gameAccepted Answerasked 5 years ago
Simultaneous client requests to create game sessionsAccepted Answerasked a year ago
How GameLift Local works with game sessionsAccepted Answerasked a year ago
How to send messages with GameLift Client in Javaasked 7 months ago
Create client in UnityAccepted Answerasked 5 years ago
GameLift Hosting for existing gameasked a year ago