Example #1
0
        public async Task DownloadRemoteConfig()
        {
            var request = CommonRequest.GetDownloadRemoteConfigVersionMessageRequest(Client);

            var requests = CommonRequest.FillRequest(request, Client, false, false);

            var serverRequest  = GetRequestBuilder().GetRequestEnvelope(requests);
            var serverResponse = await PostProto <Request>(serverRequest).ConfigureAwait(false);

            ParseServerResponse(serverResponse);
            if (serverResponse.StatusCode == ResponseEnvelope.Types.StatusCode.Redirect)
            {
                await DownloadRemoteConfig().ConfigureAwait(false);

                return;
            }

            var responses = serverResponse.Returns;

            if ((responses != null) && (responses.Count > 0))
            {
                var downloadRemoteConfigVersionResponse = new DownloadRemoteConfigVersionResponse();
                downloadRemoteConfigVersionResponse.MergeFrom(responses[0]);
                CommonRequest.ProcessDownloadRemoteConfigVersionResponse(Client, downloadRemoteConfigVersionResponse);

                CommonRequest.ProcessCommonResponses(Client, responses, false, false);
            }
        }
Example #2
0
 public static void ProcessDownloadRemoteConfigVersionResponse(Client client, DownloadRemoteConfigVersionResponse response)
 {
     if (response == null)
     {
         return;
     }
     // TODO: do something with this information
     Logger.Debug("Result:" + response.Result);
     if (response.Result == DownloadRemoteConfigVersionResponse.Types.Result.Success)
     {
         Logger.Debug("AssetDigestTimestampMs:" + response.AssetDigestTimestampMs);
         Logger.Debug("ItemTemplatesTimestampMs:" + response.ItemTemplatesTimestampMs);
     }
 }
Example #3
0
        private void OnLocalConfigVersionReceived(object sender, DownloadRemoteConfigVersionResponse data)
        {
            if (!Directory.Exists("data"))
            {
                Directory.CreateDirectory("data");
            }
            var filename = "data/" + ClientManager.UserSettings.DeviceInfo.DeviceId + "_LCV.json";

            try
            {
                File.WriteAllText(filename, Serializer.ToJson(data));
            }
            catch (Exception ex1)
            {
                ClientManager.LogCaller(new LoggerEventArgs("LocalConfigVersion could not be saved sucessfully", LoggerTypes.Warning, ex1));
            }
        }
Example #4
0
        //*************************************************************************************************************//
        public async Task <MethodResult <bool> > GetRemoteConfigVersion()
        {
            var response = await _client.ClientSession.RpcClient.SendRemoteProcedureCallAsync(new Request
            {
                RequestType    = RequestType.DownloadRemoteConfigVersion,
                RequestMessage = new DownloadRemoteConfigVersionMessage
                {
                    AppVersion         = _client.VersionInt,
                    DeviceManufacturer = _client.Settings.HardwareManufacturer,
                    DeviceModel        = _client.Settings.HardwareModel,
                    Locale             = _client.LocaleInfo.TimeZone,
                    Platform           = Platform.Ios
                }.ToByteString()
            });

            DownloadRemoteConfigVersionResponse downloadRemoteConfigVersionResponse = null;

            try
            {
                downloadRemoteConfigVersionResponse = DownloadRemoteConfigVersionResponse.Parser.ParseFrom(response);
                LogCaller(new LoggerEventArgs("Download remote config version loaded", LoggerTypes.Success));

                return(new MethodResult <bool>
                {
                    Success = true
                });
            }
            catch (Exception ex)
            {
                if (response.IsEmpty)
                {
                    LogCaller(new LoggerEventArgs("Failed to request DownloadRemoteConfigVersionResponse", LoggerTypes.Exception, ex));
                }

                return(new MethodResult <bool>());
            }
        }
Example #5
0
        protected ByteString GetGlobalPacket(RequestType typ, object msg)
        {
            switch (typ)
            {
            //case RequestType.Encounter:
            //    var pl = (EncounterMessage)msg;
            //    EncounterResponse en = new EncounterResponse();
            //    return en.ToByteString();

            //case RequestType.CatchPokemon:
            //    CatchPokemonResponse cp = new CatchPokemonResponse();
            //    return cp.ToByteString();

            //case RequestType.FortSearch:
            //    FortSearchResponse fs = new FortSearchResponse();
            //    return fs.ToByteString();

            //case RequestType.FortDetails:
            //    FortDetailsResponse fd = new FortDetailsResponse();
            //    return fd.ToByteString();

            //https://github.com/msx752/PoGoEmulator/issues/23
            case RequestType.GetMapObjects:
                GetMapObjectsMessage mgmo = (GetMapObjectsMessage)msg;
                var lat = mgmo.Latitude;
                var lon = mgmo.Longitude;

                RepeatedField <MapCell> cells = Fort.GetFortsByCells(mgmo.CellId);

                GetMapObjectsResponse gmo = new GetMapObjectsResponse();
                gmo.Status = POGOProtos.Map.MapObjectsStatus.Success;
                gmo.MapCells.AddRange(cells);
                return(gmo.ToByteString());

            case RequestType.CheckChallenge:
                var c = new CheckChallengeResponse()
                {
                    ChallengeUrl = " "
                };

                //this.Log.Dbg($"TypeOfResponseMessage: {nameof(CheckChallengeResponse)}");
                return(c.ToByteString());

            //case RequestType.GetDownloadUrls:
            //    GetDownloadUrlsResponse gdu = new GetDownloadUrlsResponse();
            //    return gdu.ToByteString();

            case RequestType.DownloadSettings:
                DownloadSettingsResponse ds = new DownloadSettingsResponse();
                ds.Hash     = "2788184af4004004d6ab0740f7632983332106f6";
                ds.Settings = new POGOProtos.Settings.GlobalSettings()
                {
                    FortSettings = new FortSettings()
                    {
                        InteractionRangeMeters    = 40.25098039215686,
                        MaxTotalDeployedPokemon   = 10,
                        MaxPlayerDeployedPokemon  = 1,
                        DeployStaminaMultiplier   = 8.062745098039215,
                        DeployAttackMultiplier    = 0,
                        FarInteractionRangeMeters = 1000.0156862745098
                    },
                    MapSettings = new MapSettings()
                    {
                        PokemonVisibleRange            = 999.00196078431372,
                        PokeNavRangeMeters             = 751.0156862745098,
                        EncounterRangeMeters           = 999.25098039215686,
                        GetMapObjectsMinRefreshSeconds = 16,
                        GetMapObjectsMaxRefreshSeconds = 16,
                        GetMapObjectsMinDistanceMeters = 10.007843017578125f,
                        GoogleMapsApiKey = "AIzaSyDilRVKLXIdPBMsR41VCxx3FpoHpbSEPIc"     //change it for you
                    },
                    InventorySettings = new InventorySettings()
                    {
                        MaxPokemon   = 1000,
                        MaxBagItems  = 1000,
                        BasePokemon  = 250,
                        BaseBagItems = 350,
                        BaseEggs     = 9
                    },
                    MinimumClientVersion = "0.35.0",
                };

                //this.Log.Dbg($"TypeOfResponseMessage: {nameof(DownloadSettingsResponse)}");
                return(ds.ToByteString());

            case RequestType.DownloadRemoteConfigVersion:
                DownloadRemoteConfigVersionResponse drcv = new DownloadRemoteConfigVersionResponse();
                drcv.Result = DownloadRemoteConfigVersionResponse.Types.Result.Success;
                drcv.ItemTemplatesTimestampMs = 1471650700946;
                drcv.AssetDigestTimestampMs   = 1467338276561000;

                //this.Log.Dbg($"TypeOfResponseMessage: {nameof(DownloadRemoteConfigVersionResponse)}");
                return(drcv.ToByteString());

            case RequestType.DownloadItemTemplates:
                var dit = GlobalSettings.GameMaster.Decode;

                //this.Log.Dbg($"TypeOfResponseMessage: {nameof(DownloadItemTemplatesResponse)}");
                return(dit.ToByteString());

            default:
                throw new Exception($"unknown (Global) Returns type: {typ}");
            }
        }
 /// <summary>
 /// Provides a safe way to invoke the <see cref="DownloadRemoteConfigVersionReceived" /> event.
 /// </summary>
 /// <param name="value"></param>
 public void RaiseDownloadRemoteConfigVersionReceived(DownloadRemoteConfigVersionResponse value) => DownloadRemoteConfigVersionReceived?.Invoke(this, value);
Example #7
0
 internal void OnRemoteConfigVersionReceived(DownloadRemoteConfigVersionResponse downloadRemoteConfigVersionResponse)
 {
     RemoteConfigVersionUpdated?.Invoke(this, new DownloadRemoteConfigVersionResponse(downloadRemoteConfigVersionResponse));
 }