Native C/C++ API Events
The Native API sends events to your callback function when you call
consumeEvents. Below is a breakdown of the different types of events, along with their meaning. Note that you do not need to handle every event code, some are provided only for debugging/informational purposes.
When an event is fired, your callback function will be called, and a
kongregate_event pointer will be passed in. This structure has several fields:
- event_code - The type of event (
- result_code - The result (
- error_code - The error code, if any (
This event code is generated when the API first establishes communication with the Kongregate Client application. At this point the Kongregate Client will attempt to retrieve an authentication token for the user if they are signed in.
This event will be fired initially (even if the user is a guest) after the
KONGREGATE_EVENT_API_CONNECTED event to provide you with information about the current user. If the user is not a guest, you can use the
getGameAuthToken function to retrieve the token and authenticate the user.
This event will also be generated if the user signs in or out of the Kongregate Client while your game is running.
This event is generated when the user's game authentication token changes during a gameplay session. This should be rare, but can happen if the user changes their password or their token is expired through other means.
This event is fired when the user's information changes. It will not be fired if the user ID or auth token changes, but rather if some other information such as username, avatar, points, or level is updated.
This is fired after a purchase is requested. The
result_code will be
KONGREGATE_RESULT_SUCCESS if the user successfully completed the purchase, or
KONGREGATE_RESULT_FAILURE if they closed the window or canceled the purchase. You can use this event as a hint to refresh the player's inventory from your game server.
This event will be fired if the API can no longer communicate with the Kongregate Client. This can happen if the user exits or uninstalls the application. While the API is disconnected, function calls will be queued and then discarded if a connection cannot automatically be re-established.
This event fires when the Kongregate Client is having trouble communicating with our servers. The client will keep retrying, but you can use this event to communicate to the user that there is a connection problem.
This event will be generated if the API is initialized incorrectly, for example passing an invalid game ID.
This event will be fired if the system detects that the Kongregate Client has been uninstalled. It is generally a good idea to inform the user that the game requires the client to function properly at this point.
This event will be fired if the system detects that the Kongregate Client has been installed. The game will automatically launch the client and establish a connection at this point.