Beispiel #1
0
        private async Task SetServer()
        {
            #region Standard intial request messages in right Order

            var getPlayerMessage      = new GetPlayerMessage();
            var checkChallengeMessage = new CheckChallengeMessage();

            #endregion

            var serverRequest = RequestBuilder.GetInitialRequestEnvelope(
                new Request
            {
                RequestType    = RequestType.GetPlayer,
                RequestMessage = getPlayerMessage.ToByteString()
            }, new Request
            {
                RequestType    = RequestType.CheckChallenge,
                RequestMessage = checkChallengeMessage.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;
        }
        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));
        }
Beispiel #3
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);
        }