Sign In Register

How can we help you today?

Start a new topic

Cached Authentication & General Gamesparks integration

So as I'm integrating GameSparks into Unity for the first time, I'm googling any questions I have, but a lot is out of date it seems.

So I'm thinking of handling my current app startup as such:

  • User opens app
  • Game loads Main Menu scene, but doesn't activate it just yet.
  • Checks if user has internet connection (right now I'm using Unity to ping, and if error I alert them that they have no connection. Searching the API I see a GameSparks.Core.GS.Available();, does that serve the same purpose? Is that better to use? Can I query its progress for my loading bar like I can with Unity's methods?).
  • If they have internet connection:
  1. Tried to use GameSparks.Api.isAuthenticated() to see if they were previously logged in/authenticated. However that doesn't seem to exist. Upon searching the API I also see GameSparks.Core.GS.Authenticated(); Are they the same, should I just use the GS.Authenticated() method instead?
  2. Anyway, if they were authenticated previously, I use that user account (how do query for it from cached data?), load their data from GameSpark, activate the Main Menu, and boom they're in.
  3. If they were not authenticated previously, I show them buttons for logging in using Facebook/Google Play/Twitter/Device. They'll choose one, I'll follow the API for registering users for the respective method, create the user with default values, activate the Main Menu, and boom they're in.
  • If they have no connection:
  1. If GameSparks.Api.isAuthenticated() is false, then I can't tell who they are and I force them to connect or suspend play till later.
  2. If isAuthenticated() or whichever equivalent returns true, then I let them play offline for max 2 days before they must reconnect. I heard setDurable in my requests queues up requests and fires them when a connection is found later, so that might help for this. However, how long do requests put into the queue by setDurable actually last? Can I set them for 2 days? Also, if they have no connection, even if isAuthenticated() returns true, how would I then get their currently saved data from the last point of save? Is that cached as well? Further, with all this caching, is this data just saved in a plain-text file where a user can just go in and change values and cheat the system, or is it encrypted?

My overall questions are basically:
  1. Is a flow of check if user is authenticated, then either logging in the cached account or making them choose an avenue to log-in a valid way to integrate GameSparks?
  2. If the user has no internet, can I allow them to play offline for max 2 days before syncing with the server?
  3. This offline saved data, is it open for manipulation by the user, or encypted?
  4. What's the new way to call GameSparks.Api.isAuthenticated()?
  5. Is GameSparks.Core.GS.Available() the same as just pinging say

I know this is a lot, even the simplified version, so thanks to any and all people who chip in!

any comments?

Hi Kevin,

I'll try my best to clear these up for you.

1. In order for a player to send an event they must be authenticated. With GameSparks used within Unity we use WebSockets as the means of sending events including Authentication Requests. If the web socket has been disconnected for a period of time a player will have to authenticate again in order to send events, it would be possible to cache the player credentials client side or to use Device Authentication but an Authentication Request must be sent in order to sign the player back into the GameSparks account and hence send events again. So to answer your 1st TL;DR question your flow seems to be fine. With regard to isAuthencated. An event sent in which a player isn't authenticated will return an error with Not Authenticated as the message. Yes an appropriate way would be to test GameSparks.Core.GS.Authenticated(); this will return true if the current user is authenticated.

2. This really would depend on the game data involved, from a possibility point of view yes this seems fine but please keep in mind our system limits, I've linked them here please also keep in mine that setDurable is intended for minor / temporary breaks in communication it is not intended as an event queue. I would be inclined to manage my own queue of events in this particular case.

3. As far as I can tell this data isn't open for manipulation.

4. I explained in point 1 about GameSparks.Core.GS.Authenticated()

5. In so far as knowing whether you have an internet connection I would imagine so, GameSparks.Core.GS.Available I don't think is queryable like the Unity methods.

Hope this helps,

 - Steve

Login to post a comment