Hi need to write lambda function for Gamelift StartMatchMaking,
Is there any example code for gamlift, how to init and call functions?
https://docs.aws.amazon.com/gamelift/latest/apireference/API_StartMatchmaking.html
Hi need to write lambda function for Gamelift StartMatchMaking,
Is there any example code for gamlift, how to init and call functions?
https://docs.aws.amazon.com/gamelift/latest/apireference/API_StartMatchmaking.html
Hi Junbo,
I meant by example code… something like below,
https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/advanced-topics.html
In my SAML app, I got maven dependency added
com.amazonaws aws-java-sdk-gamelift 1.11.831But not sure where to go from there.
@VinK - theres a simple example here in .Net that should walk you through whats required and should be simple to convert to Java: https://aws.amazon.com/blogs/gametech/creating-a-battle-royale-game-using-unity-and-amazon-gamelift/
And this has python examples: https://github.com/aws-samples/aws-gamelift-sample
I’m not sure there is an existing up-to-date Java lambda example out there.
From memory (and I’m free typing this, so apologies for code mistakes), startMatchmaking is just a matter of packing up the request object (as with any other AWS call) ie:
public StartMatchmakingResult startMatchmaking( ... pass in what you need) {
final String ticketId = randomUUID().toString();
// Need to fill this with what you need
Map<String,AttributeValue> attributes = Collections.emptyMap()
try {
return getClient(configuration).startMatchmaking(
new StartMatchmakingRequest()
.withConfigurationName(configurationName)
.withTicketId(ticketId)
.withPlayers(
playerIds.stream()
.map((id) -> new Player()
.withPlayerId(id)
.withPlayerAttributes(convertedAttributes)
...
)
.collect(toList())
)
);
// handle errors
} catch (final NotFoundException e) {
}
} catch (final InvalidRequestException e) {
}
}
I would work out how to write/deploy the simplest Java lambda and build on its complexity from there ie start with describe-matchmaking or list-fleets for example.
Hope thats helpful