public async Task <GetPlayerResponse> GetPlayer() { var profileRequest = RequestEnvelopeBuilder.GetInitialRequestEnvelope(AccessToken, _authType, CurrentLat, CurrentLng, CurrentAltitude) .WithMessage(new Request() { RequestType = RequestType.GetPlayer }); return (await _httpClient.PostProtoPayload <GetPlayerResponse>($"https://{_apiUrl}/rpc", profileRequest)); }
private async Task <TResponseTypeMessage> AwaitableOnResponseFor <TResponseTypeMessage>(RequestType requestType) where TResponseTypeMessage : IResponseMessage, IMessage, IMessage <TResponseTypeMessage>, new() { //builds the general envelope with only the request ID var requestEnvelope = RequestEnvelopeBuilder.GetRequestEnvelope(_authTicket, CurrentLat, CurrentLng, CurrentAltitude, requestType); //awaits for the IResponseMessage return (await _httpClient.PostProtoPayload <TResponseTypeMessage>($"https://{_apiUrl}/rpc", requestEnvelope)); }
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)); }
public async Task SetServer() { var serverRequest = RequestEnvelopeBuilder.GetInitialRequestEnvelope(AccessToken, _authType, CurrentLat, CurrentLng, CurrentAltitude, RequestType.GetPlayerProfile, RequestType.GetHatchedEggs, RequestType.GetInventory, RequestType.CheckAwardedBadges, RequestType.DownloadSettings); var serverResponse = await _httpClient.PostProto(Resources.RpcUrl, serverRequest); if (serverResponse.AuthTicket == null) { throw new AccessTokenExpiredException(serverResponse.Error); } _authTicket = serverResponse.AuthTicket; _apiUrl = serverResponse.ApiUrl; }
private async Task <TResponseTypeMessage> AwaitableOnResponseFor <TRequestMessageType, TResponseTypeMessage>(TRequestMessageType requestMessage, RequestType requestType) where TRequestMessageType : IRequestMessage, IMessage where TResponseTypeMessage : IResponseMessage, IMessage, IMessage <TResponseTypeMessage>, new() { //builds the general envelope with the provided request var requestEnvelope = RequestEnvelopeBuilder.GetRequestEnvelope(_authTicket, CurrentLat, CurrentLng, CurrentAltitude) .WithMessage(new Request() { RequestType = requestType, RequestMessage = requestMessage.ToByteString() }); //awaits for the IResponseMessage return (await _httpClient.PostProtoPayload <TResponseTypeMessage>($"https://{_apiUrl}/rpc", requestEnvelope)); }