DownloadSettingsResponse> > GetMapObjects() { #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(Client.CurrentLongitude, Client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = Client.CurrentLatitude, Longitude = Client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = Client.SettingsHash }; #endregion var request = GetRequestBuilder().GetRequestEnvelope(new Request[] { new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() } }); return (await PostProtoPayload <Request, GetMapObjectsResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse>(request)); }
public async Task <Tuple <GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse> > GetMapObjects() { #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = _client.CurrentLatitude, Longitude = _client.CurrentLongitude }; var CheckChallengeMessage = new CheckChallengeMessage(); var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = "2788184af4004004d6ab0740f7632983332106f6" }; #endregion var request = RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.CheckChallenge, RequestMessage = CheckChallengeMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); return(await PostProtoPayload <Request, GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse>(request)); }
public async Task <ResponseContainer <GetMapObjectsResponse> > GetMapObjects() { #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(Client.CurrentLongitude, Client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = Client.CurrentLatitude, Longitude = Client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = "05daf51635c82611d1aac95c0b051d3ec088a930" }; #endregion var request = RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); var response = await PostProtoPayload <Request, GetMapObjectsResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse>(request); return(new ResponseContainer <GetMapObjectsResponse>(response.Item1, response.Item2, response.Item3, response.Item4, response.Item5)); }
DownloadSettingsResponse, GetBuddyWalkedResponse> > GetMapObjects() { #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(Client.CurrentLongitude, Client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = Client.CurrentLatitude, Longitude = Client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = Client.InventoryLastUpdateTimestamp }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = Client.SettingsHash }; #endregion var getMapObjectsRequest = new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }; var request = GetRequestBuilder().GetRequestEnvelope(CommonRequest.FillRequest(getMapObjectsRequest, Client)); Tuple <GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse> response = await PostProtoPayload <Request, GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse>(request); GetInventoryResponse getInventoryResponse = response.Item4; CommonRequest.ProcessGetInventoryResponse(Client, getInventoryResponse); DownloadSettingsResponse downloadSettingsResponse = response.Item6; CommonRequest.ProcessDownloadSettingsResponse(Client, downloadSettingsResponse); CheckChallengeResponse checkChallengeResponse = response.Item2; CommonRequest.ProcessCheckChallengeResponse(Client, checkChallengeResponse); return(response); }
/// <summary> /// /// </summary> /// <returns></returns> public bool QueueMapObjectsRequest() { var message = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(Client.CurrentPosition.Longitude, Client.CurrentPosition.Latitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = Client.CurrentPosition.Latitude, Longitude = Client.CurrentPosition.Longitude }; return(Client.QueueRequest(RequestType.GetMapObjects, message)); }
public async Task<GetMapObjectsResponse> GetMapObjects() { #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = _client.CurrentLatitude, Longitude = _client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = "05daf51635c82611d1aac95c0b051d3ec088a930" }; #endregion var request = RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); return await PostProtoPayload<Request, GetMapObjectsResponse>(request); }
public async Task <GetMapObjectsResponse> GetMapObjects() { #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = _client.CurrentLatitude, Longitude = _client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = "54b359c97e46900f87211ef6e6dd0b7f2a3ea1f5" }; #endregion var request = RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); return(await PostProtoPayload <Request, GetMapObjectsResponse>(request)); }
public async Task <GetMapObjectsResponse> GetMapObjects() { var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, Latitude = _client.CurrentLatitude, Longitude = _client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = "05daf51635c82611d1aac95c0b051d3ec088a930" }; var request = _baseRpc.RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); return(await _baseRpc.PostProtoPayload <Request, GetMapObjectsResponse>(request)); }
public async Task<GetMapObjectsResponse> GetMapObjects() { var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = _client.CurrentLatitude, Longitude = _client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = "4a2e9bc330dae60e7b74fc85b98868ab4700802e" }; var request = _baseRpc.RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); return await _baseRpc.PostProtoPayload<Request, GetMapObjectsResponse>(request); }
public async Task <GetMapObjectsResponse> GetMapObjects() { GetMapObjectsMessage mapObjectMessage = new GetMapObjectsMessage() { Latitude = CurrentLat, Longitude = CurrentLng, }; mapObjectMessage.SinceTimestampMs.Add(new long[21]); mapObjectMessage.CellId.Add(S2Helper.GetNearbyCellIds(CurrentLng, CurrentLat)); RequestEnvelope envelope = RequestEnvelopeBuilder.GetRequestEnvelope(_authTicket, CurrentLat, CurrentLng, CurrentAltitude); envelope.WithMessage(new Request() { RequestMessage = mapObjectMessage.ToByteString(), RequestType = RequestType.GetMapObjects }) .WithMessage(new Request() { RequestType = RequestType.GetHatchedEggs }) .WithMessage(new Request() { RequestType = RequestType.GetInventory, RequestMessage = new GetInventoryMessage() { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }.ToByteString() }) .WithMessage(new Request() { RequestType = RequestType.CheckAwardedBadges }) .WithMessage(new Request() { RequestType = RequestType.DownloadSettings, RequestMessage = new DownloadSettingsMessage() { Hash = "4a2e9bc330dae60e7b74fc85b98868ab4700802e" }.ToByteString() }); return (await _httpClient.PostProtoPayload <GetMapObjectsResponse>($"https://{_apiUrl}/rpc", envelope)); }
<GetMapObjectsResponse> GetMapObjects(bool forceRequest = false) { // In case we did last _minSecondsBetweenMapCalls before, we return the cached response if (_lastGetMapRequest.AddSeconds(_minSecondsBetweenMapCalls).Ticks > DateTime.UtcNow.Ticks && !forceRequest && _cachedGetMapResponse != null ) { return(_cachedGetMapResponse); } var cellIds = S2Helper.GetNearbyCellIds(Client.CurrentLongitude, Client.CurrentLatitude).ToArray(); var sinceTimeMs = new long[cellIds.Length]; for (var index = 0; index < cellIds.Length; index++) { sinceTimeMs[index] = 0; } var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { cellIds }, SinceTimestampMs = { sinceTimeMs }, Latitude = Client.CurrentLatitude, Longitude = Client.CurrentLongitude }; var request = new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }; _cachedGetMapResponse = await PostProtoPayloadCommonR <Request, GetMapObjectsResponse>(request).ConfigureAwait(false); _lastGetMapRequest = DateTime.UtcNow; return(_cachedGetMapResponse); }
public async Task <GetMapObjectsResponse> GetMapObjects() { #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = _client.CurrentLatitude, Longitude = _client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = "05daf51635c82611d1aac95c0b051d3ec088a930" }; #endregion var request = RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); var response = await PostProtoPayload <Request, GetMapObjectsResponse>(request); lock (Client._lock) { _client._map.Invoke(new MethodInvoker(delegate { var mapPointOverlay = _client._map.Overlays[2]; mapPointOverlay.Markers.Clear(); var pokemonOverlay = _client._map.Overlays[3]; foreach (var mapPoint in response.MapCells) { if (_client.Settings.PurePokemonMode) { foreach (var spawn in mapPoint.SpawnPoints) { mapPointOverlay.Markers.Add(new GMarkerGoogle(new GMap.NET.PointLatLng(spawn.Latitude, spawn.Longitude), GMarkerGoogleType.brown_small)); } } else { foreach (var fort in mapPoint.Forts) { if (fort.Type == FortType.Checkpoint) { mapPointOverlay.Markers.Add(new GMarkerGoogle(new GMap.NET.PointLatLng(fort.Latitude, fort.Longitude), GMarkerGoogleType.blue_small)); } } } GetPokemonFromPokeVision(pokemonOverlay); //foreach (var pokemon in mapPoint.WildPokemons) //{ // pokemonOverlay.Markers.Add(new GMarkerGoogle(new GMap.NET.PointLatLng(pokemon.Latitude, pokemon.Longitude), //Images.GetPokemonImage((int)pokemon.PokemonData.PokemonId))); //} } })); } return(response); }
/// <summary> /// /// </summary> /// <param name="force">For thread wait until next api call available to use</param> /// <param name="updateCache">Allow update cache, in some case we don't want update cache, snipe pokemon is an example</param> /// <returns></returns> public async Task <GetMapObjectsResponse> GetMapObjects(bool force = false, bool updateCache = true) { if (force) { var t = GetMilisSecondUntilRefreshMapAvail(); //wait until get map available if (t > 0) { await Task.Delay(t).ConfigureAwait(false); } } if (!CanRefreshMap()) { return(force ? await GetMapObjects(force, updateCache).ConfigureAwait(false) : LastGetMapObjectResponse); // If we cannot refresh the map, return the cached response. } var lat = Client.CurrentLatitude; var lon = Client.CurrentLongitude; var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(lon, lat) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = lat, Longitude = lon }; var getMapObjectsRequest = new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }; var request = await GetRequestBuilder().GetRequestEnvelope(CommonRequest.FillRequest(getMapObjectsRequest, Client)).ConfigureAwait(false); Tuple <GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetHoloInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse> response = await PostProtoPayload <Request, GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetHoloInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse>(request).ConfigureAwait(false); GetHoloInventoryResponse getHoloInventoryResponse = response.Item4; CommonRequest.ProcessGetHoloInventoryResponse(Client, getHoloInventoryResponse); DownloadSettingsResponse downloadSettingsResponse = response.Item6; CommonRequest.ProcessDownloadSettingsResponse(Client, downloadSettingsResponse); CheckChallengeResponse checkChallengeResponse = response.Item2; CommonRequest.ProcessCheckChallengeResponse(Client, checkChallengeResponse); LastRpcMapObjectsRequestMs = Util.TimeUtil.GetCurrentTimestampInMilliseconds(); var numCells = response.Item1.MapCells.Count; var numCellsWithForts = response.Item1.MapCells.Count(x => x.Forts.Count > 0); var numCellsWithNearbyPokemon = response.Item1.MapCells.Count(x => x.NearbyPokemons.Count > 0); var numCellsWithWildPokemon = response.Item1.MapCells.Count(x => x.WildPokemons.Count > 0); // Only cache good responses if (updateCache && numCells > 0 && (numCellsWithForts > 0 || numCellsWithNearbyPokemon > 0 || numCellsWithWildPokemon > 0)) { // Good map response since we got at least a fort or pokemon in our cells. LastGetMapObjectResponse = response.Item1; LastGeoCoordinateMapObjectsRequest = new GeoCoordinate(lat, lon); } if (updateCache && LastGetMapObjectResponse == null) { LastGetMapObjectResponse = response.Item1; } return(response.Item1); }
DownloadSettingsResponse, GetBuddyWalkedResponse> > GetMapObjects(bool forceRequest = false) { // In case we did last _minSecondsBetweenMapCalls before, we return the cached response if (_lastGetMapRequest.AddSeconds(_minSecondsBetweenMapCalls).Ticks > DateTime.UtcNow.Ticks && !forceRequest) { return(_cachedGetMapResponse); } #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(Client.CurrentLongitude, Client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = Client.CurrentLatitude, Longitude = Client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = Client.InventoryLastUpdateTimestamp }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = Client.SettingsHash }; #endregion var getMapObjectsRequest = new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }; var request = await GetRequestBuilder().GetRequestEnvelope(CommonRequest.FillRequest(getMapObjectsRequest, Client)).ConfigureAwait(false); Tuple <GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse> _getMapObjectsResponse = await PostProtoPayload <Request, GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse>(request).ConfigureAwait(false); GetInventoryResponse getInventoryResponse = _getMapObjectsResponse.Item4; CommonRequest.ProcessGetInventoryResponse(Client, getInventoryResponse); DownloadSettingsResponse downloadSettingsResponse = _getMapObjectsResponse.Item6; CommonRequest.ProcessDownloadSettingsResponse(Client, downloadSettingsResponse); CheckChallengeResponse checkChallengeResponse = _getMapObjectsResponse.Item2; CommonRequest.ProcessCheckChallengeResponse(Client, checkChallengeResponse); // Here we refresh last time this request was done and cache _lastGetMapRequest = DateTime.UtcNow; _cachedGetMapResponse = _getMapObjectsResponse; return(_getMapObjectsResponse); }
public async Task <Tuple <GetMapObjectsResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse> > GetMapObjects() { while (CanGetMap == false) { await Task.Delay(150); } CanGetMap = false; var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(_client.CurrentLongitude, _client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = _client.CurrentLatitude, Longitude = _client.CurrentLongitude }; var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = "05daf51635c82611d1aac95c0b051d3ec088a930" }; var request = _baseRpc.RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); var response = await _baseRpc.PostProtoPayload <Request, GetMapObjectsResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse>(request); _pokemons.AddRange(response.Item1.MapCells.SelectMany(x => x.CatchablePokemons)); //var pokestops = response.Item1.MapCells.SelectMany(t => t.Forts).Where(x => x.Type == FortType.Checkpoint); //_pokestops.AddRange(pokestops); //var newMapObjects = response.MapCells.SelectMany(x => x.WildPokemons).Select(t => new MapPokemon() //{ // EncounterId = t.EncounterId, // ExpirationTimestampMs = t.TimeTillHiddenMs, // Latitude = t.Latitude, // Longitude = t.Longitude, // PokemonId = t.PokemonData.PokemonId, // SpawnPointId = t.SpawnPointId //}); //_pokemons.AddRange(newMapObjects); //var lurePokemon = // response.MapCells.SelectMany(f => f.Forts).Where(t => t.LureInfo != null).Select(l => new MapPokemon() // { // EncounterId = l.LureInfo.EncounterId, // ExpirationTimestampMs = l.LureInfo.LureExpiresTimestampMs, // Latitude = l.Latitude, // Longitude = l.Longitude, // PokemonId = l.LureInfo.ActivePokemonId, // SpawnPointId = l.Id // }); //_pokemons.AddRange(lurePokemon); _pokemons = _pokemons.Where(t => t.ExpirationTimestampMs > DateTime.UtcNow.ToUnixTime()).ToList(); return(response); }
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}"); } }
DownloadSettingsResponse> > GetMapObjects() { #region Messages var getMapObjectsMessage = new GetMapObjectsMessage { CellId = { S2Helper.GetNearbyCellIds(Client.CurrentLongitude, Client.CurrentLatitude) }, SinceTimestampMs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Latitude = Client.CurrentLatitude, Longitude = Client.CurrentLongitude }; var checkChallengeMessage = new CheckChallengeMessage(); var getHatchedEggsMessage = new GetHatchedEggsMessage(); var getInventoryMessage = new GetInventoryMessage { LastTimestampMs = DateTime.UtcNow.ToUnixTime() // Should be timestamp of last inventory response, no? }; var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage(); var downloadSettingsMessage = new DownloadSettingsMessage { Hash = _client.Download.DownloadSettingsHash }; #endregion var request = RequestBuilder.GetRequestEnvelope( new Request { RequestType = RequestType.GetMapObjects, RequestMessage = getMapObjectsMessage.ToByteString() }, new Request { RequestType = RequestType.CheckChallenge, RequestMessage = checkChallengeMessage.ToByteString() }, new Request { RequestType = RequestType.GetHatchedEggs, RequestMessage = getHatchedEggsMessage.ToByteString() }, new Request { RequestType = RequestType.GetInventory, RequestMessage = getInventoryMessage.ToByteString() }, new Request { RequestType = RequestType.CheckAwardedBadges, RequestMessage = checkAwardedBadgesMessage.ToByteString() }, new Request { RequestType = RequestType.DownloadSettings, RequestMessage = downloadSettingsMessage.ToByteString() }); var response = await PostProtoPayload <Request, GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse>(request); /* Temporary inserted here from 2.0 - there is better mechanism */ _client.ProcessMessages <GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse>(response); _client.Download.DownloadSettingsHash = response?.Item6?.Hash ?? ""; return(response); }