This is a follow up on our previous article. If you have not read that already, you can read that first.
As mentioned previously, Golang Server SDK allows you to more easily shift logic implementation from game clients to the backend. Here is another example of that. For this, we will use the Tic Tac Toe sample app which is included with our Golang Server SDK.
Here is the overview of the tic tac toe sample app. It consists of two parts:
We validate the access token before executing logic implemented in the backend.
To start a match, the Lambda function will send notification for both player 1 and player 2 via Lobby service.
Requests to make a move from client for both player 1 and player 2 are handled in the makeMoveHandler method. In this method, a player movement will also be communicated to the other player via Lobby service.
To make it easy to deploy the lambda function, this sample app uses a SAM template. You only need to edit a few things in template.yml before deploying.
2. Build and deploy.
3. Done! You should be able to find the API URL in AWS Console.
The client is available in the client directory inside the sample app. Before running the client, you need to set a few environment variables.
b. Run the client and login with the first user account
2. Open the second command line terminal, set the required environment variables and run the client (same as step 1) but login using the second user account.
3. Proceed to create matchmaking in both the first and second terminal. If successful, the tic tac toe game will start.
4. Both user terminals will get updated on every move. This updated information is sent to the AccelByte Lobby service and then sent to the both players via websocket.
5. At the end of the game, there will be a confirmation message on which player won.
Will there be more language runtimes supported, like TypeScript, C#, or Java?
Yes! Please reach out to us if you are interested to learn more about the Service SDKs we have in the works.
You can find our Golang Server SDK in our public Github. Interested in learning more about our solutions? Get in touch here.