question

brendan avatar image
brendan asked

How could I register an event listener inside of my game?

Noeski
started a topic on Fri, 28 August 2015 at 12:11 PM

All of the APIs are relying on the client to poll the server so how could I know when an item or gold for example increase from the server without polling? Are there any examples of how this is done in a real world scenario?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

2 Comments
Noeski said on Fri, 28 August 2015 at 12:34 PM

Also another example would be player interaction - a player 'attacks' another player, how would you receive that event?


Brendan Vanous said on Fri, 28 August 2015 at 2:31 PM

Triggering logic is, broadly speaking, the result of an API call - whether from the Client or a developer-owned Server/Admin call. In the case of your second example, and assuming that your listener is intended to notify that player that they're being attacked, you could use a SendPushNotification call via Cloud Script to let the player know. The action, in this case, is being triggered by the player who is attacking - it is in the processing of his attack that the call would be made to notify the other player. Specific to regenerating virtual currencies, the player's current balance is computed when it is returned (by any call - player or server initiated). Otherwise, we would need to compute the current balance for all players, across all VCs in all games, whether or not those players are still actually playing those games, on a frequent basis. That would drive our compute costs up, requiring us to charge more for our service - something we prefer to avoid. We are in the process of creating an event system which will allow for a broad range of triggered actions, though the main element tracked for players who haven't signed in will be the elapsed time since their last sign-in (which you could then use to trigger a message to bring them back). We'll be posting more information about that later this year.

Brendan

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.