public GeolocalizationBackgroundWorker(INetworkClient networkClient, IButterflyMobileClient butterflyMobileClient) : base(20000, System.Threading.ThreadPriority.BelowNormal) { this.butterflyMobileClient = butterflyMobileClient; this.networkClient = networkClient; this.genericTCPPacketSender = new GenericTCPPacketSender <ConnectedClientInfoPacket>(this.networkClient); }
protected async override void Work() { try { if (!googleApiClient.IsConnected) { this.OnStart(null); } LocationRequest lr = LocationRequest.Create(); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().AddLocationRequest(lr); builder.SetAlwaysShow(true); var result = await LocationServices.SettingsApi.CheckLocationSettingsAsync(googleApiClient, builder.Build()); var res = LocationServices.FusedLocationApi.GetLastLocation(googleApiClient); if (res != null) { this.genericTCPPacketSender = new GenericTCPPacketSender <ConnectedClientInfoPacket>(this.networkClient); this.genericTCPPacketSender.Send(new ConnectedClientInfoPacket() { ConnectedClientViewModel = new ConnectedClientViewModel() { IsAdmin = false, Latitude = res.Latitude, Longitude = res.Longitude, Machine = CrossDeviceInfo.Current.Model, Name = "Antek" } }); } } catch (FeatureNotEnabledException ex) { throw; } catch (Exception ex) { throw ex; } }
public ConnectedClientInfoUpdaterBackgroundWorker(INetworkClient networkClient) : base(5000, ThreadPriority.AboveNormal) { this.networkClient = networkClient; this.genericTCPPacketSender = new GenericTCPPacketSender <ConnectedClientInfoPacket>(networkClient); }