Пример #1
0
        static public bool ParseGetEncouragementsResponse(byte[] responseBytes)
        {
            Encouragement.EncouragementGetResponse getEncouragementResponse =
                Deserialize(responseBytes, typeof(Encouragement.EncouragementGetResponse)) as Encouragement.EncouragementGetResponse;

            Logger.BasicLog("I got an encouragement get response with " + getEncouragementResponse.encouragement_data.Count + " encouragements.");

            foreach (Encouragement.EncouragementData encouragementData in getEncouragementResponse.encouragement_data)
            {
                ProblemPart[] encouragementParts = new ProblemPart[encouragementData.encouragement_atoms.Count];
                for (int i = 0; i < encouragementParts.Length; i++)
                {
                    encouragementParts[i] = ProblemPart.CreateProblemPart(encouragementData.encouragement_atoms[i]);
                }
                ThinksyEvents.InvokeEncouragementReceived(encouragementParts);
            }

            ThinksyPlugin.NewHeartbeatTiming(getEncouragementResponse.frames_per_heartbeat);
            if (getEncouragementResponse.force_pull)
            {
                ProblemKeeper.PullNewProblems();
            }

            return(true);
        }
Пример #2
0
        static public bool ParseGetProblemResponse(byte[] responseBytes)
        {
            Problem.ProblemGetResponse getProblemResponse =
                Deserialize(responseBytes, typeof(Problem.ProblemGetResponse)) as Problem.ProblemGetResponse;
            //Debug.Log("has message: " + reply.HasMessage);
            //Debug.Log("message length: " + reply.Message.Length);
            //Debug.Log("has problem get: " + reply.HasProblemGet);
            if (getProblemResponse.problems.Count != ProblemKeeper.PROBLEMS_PER_PULL)
            {
                Logger.BasicLog("How wude.  I asked for " + ProblemKeeper.PROBLEMS_PER_PULL + " problems, but I only got " + getProblemResponse.problems.Count);
            }
            if (getProblemResponse.problems.Count == 0)
            {
                throw new Exception("no problems in problem response.");
            }

            ProblemKeeper.ReplaceQueue(getProblemResponse);

            return(true);
        }