ShowEmergencyWindow() public static method

Shows a window indicating that something horrible has happened. Use this if something horrible happens.
public static ShowEmergencyWindow ( string additionalMessage ) : void
additionalMessage string
return void
示例#1
0
        static private void GetProblemsFromSeed()
        {
            string seedPath = SeedFilePath();

            byte []      seedContents = System.IO.File.ReadAllBytes(seedPath);
            MemoryStream seedStream   = new MemoryStream(seedContents);

            if (seedContents.Length == 0)
            {
                ThinksyPlugin.ShowEmergencyWindow("The seed file is empty! (" + seedPath + ")");
                throw new Exception("The seed file is empty!");
            }
            //Message.Problem.ProblemGetResponse problemGet = Message.Problem.ProblemGetResponse.ParseFrom (seedContents);
            //Message.Problem.ProblemGetResponse problemGet = ProtoBuf.Serializer.Deserialize<Message.Problem.ProblemGetResponse> (seedStream);

            ThinksyProtosSerializer customSerializer = new ThinksyProtosSerializer();

            Message.Problem.ProblemGetResponse problemGet =
                customSerializer.Deserialize(seedStream, null, typeof(Message.Problem.ProblemGetResponse))
                as Message.Problem.ProblemGetResponse;


            for (int i = 0; i < problemGet.problems.Count; i++)
            {
                Message.Problem.ProblemData problem = problemGet.problems[i];
                ProblemKeeper.AddProblemsToProblemQueue(problem);
            }
        }
示例#2
0
 /// <summary>
 /// Returns false for an error, or true for no errors.
 /// </summary>
 static public bool NetworkErrorChecking(WWW recvResult)
 {
     //Did we receive any response?
     if (!string.IsNullOrEmpty(recvResult.error))
     {
         UnityEngine.Debug.LogWarning(recvResult.error);
         if (secretStagingMode)
         {
             ThinksyPlugin.ShowEmergencyWindow(recvResult.error);
         }
         SenseixSession.SetSessionState(false);
         if (recvResult.error.Equals(401))
         {
             //This is probably a problem with an auth token
         }
         else if (recvResult.error.Equals(422))
         {
             //This is probably a server side error
         }
         else
         {
             //This is probably a 500.
             //This is a bad place in which to be.
         }
         return(false);
     }
     return(true);
 }
示例#3
0
        static public string SeedFilePath()
        {
            string[] files = Directory.GetFiles(Application.persistentDataPath, "*" + SEED_FILE_EXTENSION);

            foreach (string filename in files)
            {             //test overrides everything
                if (filename.Contains("test"))
                {
                    return(filename);
                }
            }

            //next priority is player specific
            string playerSeedPath = PlayerSeedPath();

            if (File.Exists(playerSeedPath))
            {
                return(playerSeedPath);
            }

            //then failsafe or anything else
            if (files.Length == 0)
            {
                ThinksyPlugin.ShowEmergencyWindow("No seed files found in " + Application.persistentDataPath);
                throw new Exception("No seed files found in " + Application.persistentDataPath);
            }
            return(files[0]);
        }
    private void AnswerGiven(string answer)
    {
        int answerNumber = -1;

        try
        {
            answerNumber = System.Convert.ToInt16(answer);
        }
        catch
        {
            continueButtonText.text = "Please input an integer";
            return;
        }

        if (answerNumber != firstNumber * secondNumber)
        {
            continueButtonText.text = "That's not right...";
            return;
        }

        if (answerNumber == -1)
        {
            ThinksyPlugin.ShowEmergencyWindow("An error was encountered during the parent gate question.");
        }

        thisMenu.SetActive(false);
        nextMenu.SetActive(true);
    }
示例#5
0
 static public Senseix.Message.Problem.ProblemData GetProblem()
 {
     CheckProblemPull();
     if (newProblems.Count == 0)
     {
         GetProblemsFromSeed();
     }
     if (newProblems.Count == 0)
     {
         ThinksyPlugin.ShowEmergencyWindow("We ran out of problems.  That really shouldn't happen!");
     }
     return((Senseix.Message.Problem.ProblemData)newProblems.Dequeue());
 }
示例#6
0
        public static void HandleResult(WWW recvResult, ResponseHandlerDelegate resultHandler)
        {
            byte[] responseBytes = new byte[0];
            if (NetworkErrorChecking(recvResult))
            {
                responseBytes = recvResult.bytes;
                //UnityEngine.Debug.Log ("Recv result is " + recvResult.bytes.Length + " bytes long");
                //UnityEngine.Debug.Log ("parse response");

                if (responseBytes.Length == 0)
                {
                    Logger.BasicLog("I got an empty server response.  This is normal for certain responses.");
                    return;
                }

                bool isAnError = true;
                try
                {
                    isAnError = Response.ParseServerErrorResponse(responseBytes);
                }
                catch
                {
                    HandleNonerrorResponse(responseBytes, resultHandler);
                }
                if (!isAnError)
                {
                    HandleNonerrorResponse(responseBytes, resultHandler);
                }
            }
            else
            {
                string logString = "A SenseiX message (Handler: " + resultHandler.Method.Name + ") had an error.  " +
                                   "Most likely internet connectivity issues.";
                UnityEngine.Debug.LogWarning(logString);
                if (secretStagingMode)
                {
                    ThinksyPlugin.ShowEmergencyWindow(logString);
                }
                SenseixSession.SetSessionState(false);
            }
            return;
        }
示例#7
0
        static public bool ParseServerErrorResponse(byte[] responseBytes)
        {
            Debug.ServerErrorResponse serverErrorResponse =
                Deserialize(responseBytes, typeof(Debug.ServerErrorResponse)) as Debug.ServerErrorResponse;

            if (serverErrorResponse.message.Length == 0)
            {
                return(false);
            }

            string logString = "I got a server error response.  Here is the message: " +
                               serverErrorResponse.message;

            if (Request.IsInSecretStagingMode())
            {
                ThinksyPlugin.ShowEmergencyWindow(logString);
            }

            UnityEngine.Debug.LogError(logString);
            return(true);
        }
示例#8
0
        static public void CopyFailsafeOver()
        {
            string failsafeFileName    = "failsafe";
            string failsafeDestination = System.IO.Path.Combine(Application.persistentDataPath, failsafeFileName + SEED_FILE_EXTENSION);

            TextAsset failsafeAsset = Resources.Load <TextAsset>(failsafeFileName);

            byte[] failsafeContents = failsafeAsset.bytes;

            try
            {
                FileStream newFile = System.IO.File.Create(failsafeDestination);
                SenseixSession.DoFileFlagging(failsafeDestination);
                newFile.Close();
                System.IO.File.WriteAllBytes(failsafeDestination, failsafeContents);
            }
            catch
            {
                ThinksyPlugin.ShowEmergencyWindow("An error occurred while creating a failsafe seed file in " + failsafeDestination);
            }
        }
示例#9
0
        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());
        }