public static IEnumerator LimitedInitializeSenseix(string newAccessToken) { if (isInitializing) { Logger.BasicLog("already initializing"); yield break; } isInitializing = true; yield return(GetSingletonInstance().StartCoroutine(WaitForWebGLInitializing())); SetSessionState(true); accessToken = newAccessToken; if (CheckAccessToken() == -1) { throw new Exception("The Thinksy Token you have provided is not of a valid length, please" + " register at https://developer.thinksylearn.com/ to create a valid key. Then, fill " + "in the Game Access Token field of the ThinksyPlugin script on the Thinksy Prefab." + " You can also test offline by checking the testing mode boolean on the Thinksy Prefab."); } //Creates a temporary account based on device id //returns an auth token. This is Syncronous. //Debug.Log("registering device"); yield return(GetSingletonInstance().StartCoroutine(RegisterDevice())); //Debug.Log ("listing players"); yield return(GetSingletonInstance().StartCoroutine(ListPlayers())); //Debug.Log("register all players"); yield return(GetSingletonInstance().StartCoroutine(RegisterAllPlayers())); EndInitialize(); }
static public void DrainProblems() { int problemsDrained = 0; while (newProblems.Count > 0) //don't give it a little wiggle room... { newProblems.Dequeue(); problemsDrained++; } Logger.BasicLog(problemsDrained + " problems drained."); }
public static void PushAllProblems() { if (answeredProblems.Count == 0) { return; } Logger.BasicLog("Pushing current queue of " + answeredProblems.Count + " problems."); Senseix.Message.Request.GetSingletonInstance().StartCoroutine( Message.Request.PostProblems(Senseix.SenseixSession.GetCurrentPlayerID(), answeredProblems)); answeredProblems.Clear(); }
public static IEnumerator InitializeSenseix(string newAccessToken) { //Debug.Log ("initializing"); if (isInitializing) { Logger.BasicLog("already initializing"); yield break; } isInitializing = true; yield return(GetSingletonInstance().StartCoroutine(WaitForWebGLInitializing())); SetSessionState(true); accessToken = newAccessToken; if (CheckAccessToken() == -1) { throw new Exception("The Thinksy Token you have provided is not of a valid length, please" + " register at https://developer.thinksylearn.com/ to create a valid key. Then, fill " + "in the Game Access Token field of the ThinksyPlugin script on the Thinksy Prefab." + " You can also test offline by checking the testing mode boolean on the Thinksy Prefab."); } //Creates a temporary account based on device id //returns an auth token. This is Syncronous. //Debug.Log("registering device"); yield return(GetSingletonInstance().StartCoroutine(RegisterDevice())); //Debug.Log ("listing players"); yield return(GetSingletonInstance().StartCoroutine(ListPlayers())); //Debug.Log("register all players"); yield return(GetSingletonInstance().StartCoroutine(RegisterAllPlayers())); //Debug.Log("submit cache"); SenseixSession.CheckProblemPostCacheSubmission(); //SenseixPlugin.ShowEmergencyWindow ("testing"); //yield return GetSingletonInstance().StartCoroutine(Message.Request.UpdatePlayerScore (GetCurrentPlayerID(), 0)); //yield return GetSingletonInstance().StartCoroutine(Message.Request.GetPlayerRank (GetCurrentPlayerID ())); yield return(Message.Request.GetSingletonInstance().StartCoroutine( Message.Request.GetProblems(SenseixSession.GetCurrentPlayerID(), ProblemKeeper.PROBLEMS_PER_PULL))); ThinksyPlugin.GetMostRecentProblem(); isInitializing = false; }
private static ConnectionIndicator GetSingletonInstance() { if (singletonInstance == null) { singletonInstance = FindObjectOfType <ConnectionIndicator>(); } if (singletonInstance == null) { if (!warningThrown) { Logger.BasicLog("There is no ConnectionIndicator enabled in scene."); } warningThrown = true; } return(singletonInstance); }
static private void ReplaceSeed(Message.Problem.ProblemGetResponse reply) { Logger.BasicLog("Replacing seed file."); MemoryStream stream = new MemoryStream(); ThinksyProtosSerializer customSerializer = new ThinksyProtosSerializer(); customSerializer.Serialize(stream, reply); byte[] replacementBytes = stream.ToArray(); try { FileStream newFile = System.IO.File.Create(PlayerSeedPath()); SenseixSession.DoFileFlagging(PlayerSeedPath()); newFile.Close(); } catch { ThinksyPlugin.ShowEmergencyWindow("An error occurred while creating a seedfile in " + PlayerSeedPath()); } stream.Close(); System.IO.File.WriteAllBytes(SeedFilePath(), replacementBytes); SenseixSession.DoFileFlagging(SeedFilePath()); }
public static void Heartbeat() { Logger.BasicLog("thump thump"); Senseix.SenseixSession.GetEncouragements(); ProblemKeeper.PushAllProblems(); }