public bool Stop() { var request = new StopRequest { Process = grpcSbProcess }; StopResponse response = null; if (connection.InvokeRpc(() => { response = client.Stop(request); })) { return(response.Result); } return(false); }
public async Task <StopResponse> Stop() { await BeginRunStateTransition(); var fbb = BeginRequest(); StopRequest.StartStopRequest(fbb); int requestDataOffset = StopRequest.EndStopRequest(fbb); var response = await CommitRequest(fbb, RequestData.StopRequest, requestDataOffset); System.Diagnostics.Debug.Assert(response.ResponseDataType == ResponseData.StopResponse); var stopResponse = new StopResponse(); response.GetResponseData(stopResponse); await CompleteRunStateTransition(RunState.Paused); return(stopResponse); }
public async Task <List <Stop> > GetStopByAddress(string address, double distance_in_miles = 0, string type = "brewery") { var maxMiles = 0d; if (type == "brewery") { maxMiles = 25d; } else if (type == "hotel") { maxMiles = 3d; } if (distance_in_miles != 0) { maxMiles = distance_in_miles; } var coordResults = await GetCoordinatesByAddress(address); var distance_In_Meters = maxMiles * 1609.34; StopResponse result = new StopResponse(); if (coordResults != null && coordResults.results.Length > 0 && coordResults.results[0].geometry != null) { var httpResponse = await _httpClient.GetAsync($"place/nearbysearch/json?location={coordResults.results[0].geometry.location.lat},{coordResults.results[0].geometry.location.lng}&radius={distance_In_Meters}&keyword={type}&key={_settings.ApiKey}"); httpResponse.EnsureSuccessStatusCode(); var content = await httpResponse.Content.ReadAsStringAsync(); result = JsonSerializer.Deserialize <StopResponse>(content, _options); result.StartingLatitude = coordResults.results[0].geometry.location.lat; result.StartingLongitude = coordResults.results[0].geometry.location.lng; //getting photo api if (result != null && result.Results != null) { foreach (var brewery in result.Results) { if (brewery.Photos != null && brewery.Photos.Count > 0) { brewery.photoURL = $"https://maps.googleapis.com/maps/api/place/photo?maxwidth=100&photoreference={brewery.Photos[0].Photo_Reference}&key={_settings.ApiKey}"; } } } } List <Stop> stops = new List <Stop>(); foreach (var stop in result?.Results) { stops.Add(new Stop { Name = stop.Name, Rating = stop.Rating, Address = stop.Vicinity, Photo = stop.photoURL, IsHotel = false, //starting lat and starting long are based on the user search not based on the last stop lat or long StartingLatitiude = result.StartingLatitude, StartingLongitude = result.StartingLongitude, lat = stop.Geometry.Location.Lat, lng = stop.Geometry.Location.Lng, }); } return(stops); }
public AResponse CreateResponse(string responseData) { AResponse response = null; try { // validate length if (responseData.Length < Protocol.Instance.HeaderLength) { throw new ParserException("invalid responseData length"); } // get the header string header = responseData.Substring(0, (int)Protocol.Instance.HeaderLength); switch (_messageHeaderMapper[header]) { case MessageType.DisplayDevicesInfo: response = new DisplayDeviceInfoResponse(); break; case MessageType.Pause: response = new PauseResponse(); break; case MessageType.Play: response = new PlayResponse(); break; case MessageType.Resume: response = new ResumeResponse(); break; case MessageType.Seek: response = new SeekResponse(); break; case MessageType.SetImage: response = new SetImageResponse(); break; case MessageType.SetText: response = new SetTextResponse(); break; case MessageType.RemoveAddon: response = new RemoveAddonResponse(); break; case MessageType.Stop: response = new StopResponse(); break; case MessageType.Termination: response = new TerminationResponse(); break; case MessageType.VideoLayout: response = new VideoLayoutResponse(); break; case MessageType.Volume: response = new VolumeResponse(); break; case MessageType.WindowLayout: response = new WindowLayoutResponse(); break; case MessageType.SoundFx: response = new SoundFxResponse(); break; case MessageType.Sound3d: response = new Sound3dResponse(); break; case MessageType.MidiProperties: response = new MidiPropertiesResponse(); break; case MessageType.MidiOutputPortInfo: response = new MidiOutputPortInfoResponse(); break; case MessageType.SetMidiOutputPort: response = new SetMidiOutputPortResponse(); break; case MessageType.SetDls: response = new SetDlsResponse(); break; case MessageType.SetFrequency: response = new SetFrequencyResponse(); break; case MessageType.SetRate: response = new SetRateResponse(); break; case MessageType.SetPlayerType: response = new SetPlayerTypeResponse(); break; default: throw new ParserException("invalid message header"); } response.ParseFromString(responseData); } catch (System.Exception e) { throw e; } return(response); }