Setting up the Message Handlers

Once you've set your LogEventRequest to upload the player's score, you can now set up a NewHighScoreMessage handler. Handlers are very useful tools, which allow you to intercept messages that are passed in to your authenticated player.

For this tutorial, we'll be dealing with NewHighScoreMessage.

We'll place the initialization of the message handler in the same function which connects the GS module.

To do this use gs.getMessagerHandler() and resume to choose which type of message you wish to intercept, followed by the function which will deal with the message.

Create the function which deals with the message. The parameters of the function would take a variable of type NewHighScoreMessage. This function allows you to simplify the structure of the message and access some useful data.

In this tutorial, we retrieve the Leaderboard's name to show the highscore message as an alert.