public DriversDashboardPage() { this.InitializeComponent(); BtnTracking.Toggled += BtnTracking_Toggled; _httpClientService = new HttpClientService(); _signalRClientService = new SignalRClientService(); GlobalHelpers.HubConnection.On <LocationDto, string>("ReceiveLocation", async(locationDto, connectionId) => { var request = new GeolocationRequest(GeolocationAccuracy.High); var location = await Geolocation.GetLocationAsync(request); if (location != null) { var gpsLocation = new LocationDto(location.Latitude.ToString(), location.Longitude.ToString()) { Altitude = location.Altitude.ToString(), }; } var requestResponse = new RequestMatatuResponse { Driver = _driverEntity, LocationDto = new LocationDto(location.Latitude.ToString(), location.Longitude.ToString()), Vehicle = _driverEntity.Vehicle }; if (GlobalHelpers.HubConnection.State == HubConnectionState.Disconnected) { await GlobalHelpers.HubConnection.StartAsync(); } await GlobalHelpers.HubConnection.InvokeAsync("SendLocation", requestResponse, connectionId); }); }
public async Task SendLocation(RequestMatatuResponse requestMatatuResponse, string connectionId) { await Clients.Client(connectionId).SendAsync("RequestResponse", requestMatatuResponse); }