Esempio n. 1
0
        public static void Parse(Client client, RequestType requestType, ByteString data)
        {
            try
            {
                switch (requestType)
                {
                case RequestType.GetHoloInventory:
                    var getHoloInventoryResponse = new GetHoloInventoryResponse();
                    getHoloInventoryResponse.MergeFrom(data);
                    ProcessGetHoloInventoryResponse(client, getHoloInventoryResponse);
                    break;

                case RequestType.DownloadSettings:
                    //TODO Update settings
                    //api.getSettings().updateSettings(DownloadSettingsResponse.parseFrom(data));
                    // Update settings hash
                    var downloadSettingsResponse = new DownloadSettingsResponse();
                    downloadSettingsResponse.MergeFrom(data);
                    client.SettingsHash = downloadSettingsResponse.Hash;
                    break;
                }
            }
            catch (InvalidProtocolBufferException e)
            {
                throw e;
            }
        }
Esempio n. 2
0
        public static void ProcessCommonResponses(Client client, RepeatedField <ByteString> responses, bool processBuddyWalked = true, bool processInBox = true)
        {
            if (responses != null)
            {
                var checkChallengeResponse = new CheckChallengeResponse();
                if (responses.Count > 1)
                {
                    checkChallengeResponse.MergeFrom(responses[1]);
                    CommonRequest.ProcessCheckChallengeResponse(client, checkChallengeResponse);
                }

                var getHatchedEggsResponse = new GetHatchedEggsResponse();
                if (responses.Count > 2)
                {
                    getHatchedEggsResponse.MergeFrom(responses[2]);
                    CommonRequest.ProcessGetHatchedEggsResponse(client, getHatchedEggsResponse);
                }

                var getHoloInventoryResponse = new GetHoloInventoryResponse();
                if (responses.Count > 3)
                {
                    getHoloInventoryResponse.MergeFrom(responses[3]);
                    CommonRequest.ProcessGetHoloInventoryResponse(client, getHoloInventoryResponse);
                }

                var checkAwardedBadgesResponse = new CheckAwardedBadgesResponse();
                if (responses.Count > 4)
                {
                    checkAwardedBadgesResponse.MergeFrom(responses[4]);
                    CommonRequest.ProcessCheckAwardedBadgesResponse(client, checkAwardedBadgesResponse);
                }

                var downloadSettingsResponse = new DownloadSettingsResponse();
                if (responses.Count > 5)
                {
                    downloadSettingsResponse.MergeFrom(responses[5]);
                    CommonRequest.ProcessDownloadSettingsResponse(client, downloadSettingsResponse);
                }
                var index = 5;
                if (processBuddyWalked)
                {
                    index++;
                    var getBuddyWalkedResponse = new GetBuddyWalkedResponse();
                    if (responses.Count > index)
                    {
                        getBuddyWalkedResponse.MergeFrom(responses[index]);
                        CommonRequest.ProcessGetBuddyWalkedResponse(client, getBuddyWalkedResponse);
                    }
                }
                if (processInBox)
                {
                    index++;
                    var getInboxResponse = new GetInboxResponse();

                    if (responses.Count > index)
                    {
                        getInboxResponse.MergeFrom(responses[index]);
                        CommonRequest.ProcessGetInboxResponse(client, getInboxResponse);
                    }
                }
            }
        }