Exemplo n.º 1
0
             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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        private async Task SetServer()
        {
            {
                var getPlayerMessage      = new GetPlayerMessage();
                var getHatchedEggsMessage = new GetHatchedEggsMessage();
                var getInventoryMessage   = new GetInventoryMessage
                {
                    LastTimestampMs = DateTime.UtcNow.ToUnixTime()
                };
                var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
                var downloadSettingsMessage   = new DownloadSettingsMessage
                {
                    //05daf51635c82611d1aac95c0b051d3ec088a930
                    Hash = "05daf51635c82611d1aac95c0b051d3ec088a930"
                };

                var serverRequest = _apiBaseRpc.RequestBuilder.GetRequestEnvelope(
                    new Request
                {
                    RequestType    = RequestType.GetPlayer,
                    RequestMessage = getPlayerMessage.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()
                },
                    new Request()
                {
                    RequestType = RequestType.DownloadItemTemplates
                });

                var serverResponse = await _apiBaseRpc.PostProto <Request>(Resources.RpcUrl, serverRequest);

                if (serverResponse.AuthTicket == null)
                {
                    throw new AccessTokenExpiredException();
                }

                _client.AuthTicket = serverResponse.AuthTicket;
                _client.ApiUrl     = serverResponse.ApiUrl;
            }
        }
Exemplo n.º 4
0
        private async Task SetServer()
        {
            #region Standard intial request messages in right Order

            var getPlayerMessage      = new GetPlayerMessage();
            var getHatchedEggsMessage = new GetHatchedEggsMessage();
            var getInventoryMessage   = new GetInventoryMessage
            {
                LastTimestampMs = DateTime.UtcNow.ToUnixTime()
            };
            var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
            var downloadSettingsMessage   = new DownloadSettingsMessage
            {
                Hash = "54b359c97e46900f87211ef6e6dd0b7f2a3ea1f5" //"05daf51635c82611d1aac95c0b051d3ec088a930"
            };

            #endregion

            var serverRequest = RequestBuilder.GetInitialRequestEnvelope(
                new Request
            {
                RequestType    = RequestType.GetPlayer,
                RequestMessage = getPlayerMessage.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 serverResponse = await PostProto <Request>(Resources.RpcUrl, serverRequest);

            if (serverResponse.AuthTicket == null)
            {
                _client.AuthToken = null;
                throw new AccessTokenExpiredException();
            }

            _client.AuthTicket = serverResponse.AuthTicket;
            _client.ApiUrl     = serverResponse.ApiUrl;
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        private async Task SetServer()
        {
            #region Standard intial request messages in right Order

            var getPlayerMessage      = new GetPlayerMessage();
            var getHatchedEggsMessage = new GetHatchedEggsMessage();
            var getInventoryMessage   = new GetInventoryMessage
            {
                LastTimestampMs = DateTime.UtcNow.ToUnixTime()
            };
            var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
            var downloadSettingsMessage   = new DownloadSettingsMessage
            {
                Hash = "b8fa9757195897aae92c53dbcf8a60fb3d86d745"
            };

            #endregion

            var serverRequest = RequestBuilder.GetInitialRequestEnvelope(
                new Request
            {
                RequestType    = RequestType.GetPlayer,
                RequestMessage = getPlayerMessage.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 serverResponse = await PostProto <Request>(Resources.RpcUrl, serverRequest);

            if (serverResponse.AuthTicket == null)
            {
                _client.AuthToken = null;
                throw new AccessTokenExpiredException();
            }

            _client.AuthTicket = serverResponse.AuthTicket;
            _client.ApiUrl     = serverResponse.ApiUrl;
        }
Exemplo n.º 7
0
             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);
        }
Exemplo n.º 8
0
        private async Task SetServer()
        {
            #region Standard intial request messages in right Order

            var getPlayerMessage = new GetPlayerMessage();
            var getHatchedEggsMessage = new GetHatchedEggsMessage();
            var getInventoryMessage = new GetInventoryMessage
            {
                LastTimestampMs = DateTime.UtcNow.ToUnixTime()
            };
            var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
            var downloadSettingsMessage = new DownloadSettingsMessage
            {
                Hash = "05daf51635c82611d1aac95c0b051d3ec088a930"
            };

            #endregion

            var serverRequest = RequestBuilder.GetInitialRequestEnvelope(
                new Request
                {
                    RequestType = RequestType.GetPlayer,
                    RequestMessage = getPlayerMessage.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 serverResponse = await PostProto<Request>(Resources.RpcUrl, serverRequest);

            if (serverResponse.AuthTicket == null)
            {
                _client.AuthToken = null;
                throw new AccessTokenExpiredException();
            }

            _client.AuthTicket = serverResponse.AuthTicket;
            _client.ApiUrl = serverResponse.ApiUrl;
        }
Exemplo n.º 9
0
        private async Task SetServer()
        {
            {
                var getPlayerMessage = new GetPlayerMessage();
                var getHatchedEggsMessage = new GetHatchedEggsMessage();
                var getInventoryMessage = new GetInventoryMessage
                {
                    LastTimestampMs = DateTime.UtcNow.ToUnixTime()
                };
                var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
                var downloadSettingsMessage = new DownloadSettingsMessage
                {
                    //05daf51635c82611d1aac95c0b051d3ec088a930
                    Hash = "05daf51635c82611d1aac95c0b051d3ec088a930"
                };

                var serverRequest = _apiBaseRpc.RequestBuilder.GetRequestEnvelope(
                    new Request
                    {
                        RequestType = RequestType.GetPlayer,
                        RequestMessage = getPlayerMessage.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()
                    },
                    new Request()
                    {
                        RequestType = RequestType.DownloadItemTemplates
                    });

                var serverResponse = await _apiBaseRpc.PostProto<Request>(Resources.RpcUrl, serverRequest);

                if (serverResponse.AuthTicket == null)
                    throw new AccessTokenExpiredException();

                _client.AuthTicket = serverResponse.AuthTicket;
                _client.ApiUrl = serverResponse.ApiUrl;
            }
        }
Exemplo n.º 10
0
        private async Task SendInitialRequests()
        {
            var getPlayerMessage      = new GetPlayerMessage();
            var getHatchedEggsMessage = new GetHatchedEggsMessage();

            var epoch         = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            var lastTimeStamp = Convert.ToInt64((DateTime.UtcNow - epoch).TotalMilliseconds);

            var getInventoryMessage = new GetInventoryMessage
            {
                LastTimestampMs = lastTimeStamp
            };
            var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
            var downloadSettingsMessage   = new DownloadSettingsMessage
            {
                Hash = "05daf51635c82611d1aac95c0b051d3ec088a930"
            };

            var serverRequest = RequestGenerator.GetInitialRequestEnvelope(
                new Request
            {
                RequestType    = RequestType.GetPlayer,
                RequestMessage = getPlayerMessage.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 serverResponse = await PostProto <Request>(Constants.RpcUrl, serverRequest);

            if (serverResponse.AuthTicket == null)
            {
                _session.AccessToken.Token = null;
                //throw new AccessTokenExpiredException();
            }

            _session.AuthTicket = serverResponse.AuthTicket;
            _session.ApiUrl     = serverResponse.ApiUrl;
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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));
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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));
        }
Exemplo n.º 15
0
             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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        private async Task SetServer(bool noRetry = false)
        {
            #region Standard intial request messages in right Order

            var getPlayerMessage      = new GetPlayerMessage();
            var getHatchedEggsMessage = new GetHatchedEggsMessage();
            var getInventoryMessage   = new GetInventoryMessage
            {
                LastTimestampMs = DateTime.UtcNow.ToUnixTime()
            };
            var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
            var downloadSettingsMessage   = new DownloadSettingsMessage
            {
                Hash = _downloadHash //"05daf51635c82611d1aac95c0b051d3ec088a930"
            };

            var downloadRemoteConfigMessage = new DownloadRemoteConfigVersionMessage
            {
                Platform   = Platform.Ios,
                AppVersion = 4500
            };

            #endregion

            try
            {
                var serverRequest = RequestBuilder.GetInitialRequestEnvelope(
                    new Request
                {
                    RequestType    = RequestType.GetPlayer,
                    RequestMessage = getPlayerMessage.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()
                },
                    new Request
                {
                    RequestType    = RequestType.DownloadRemoteConfigVersion,
                    RequestMessage = downloadRemoteConfigMessage.ToByteString()
                });
                var serverResponse = await PostProto <Request>(Resources.RpcUrl, serverRequest);

                if (serverResponse.AuthTicket == null)
                {
                    _client.AuthToken = null;
                    throw new AccessTokenExpiredException(
                              "Check your internet connection and try to restart the profile");
                }
                _client.AuthTicket = serverResponse.AuthTicket;
                _client.ApiUrl     = serverResponse.ApiUrl;


                /*    var dlVerReq = RequestBuilder.GetRequestEnvelope(new Request
                 *  {
                 *      RequestType = RequestType.DownloadSettings,
                 *      RequestMessage = downloadSettingsMessage.ToByteString()
                 *  });
                 *
                 *  var dlVerResp = await PostProtoPayload<Request, DownloadSettingsResponse>(RequestType.DownloadSettings, dlVerReq);
                 */
            }
            catch (Exception)
            {
                if (!noRetry)
                {
                    await Task.Delay(15000);
                    await DoLogin();
                }
                else
                {
                    throw new Exception("Check your internet connection and try to restart the profile");
                }
            }
        }
Exemplo n.º 18
0
             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);
        }
Exemplo n.º 19
0
        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);
        }