private async ValueTask TopicReChecker() { try { var ask = await _lookup.Ask <AskResponse>(new GetTopicsUnderNamespace(NamespaceName, _subscriptionMode)).ConfigureAwait(false); var response = ask.ConvertTo <GetTopicsUnderNamespaceResponse>(); var topicsFound = response.Topics; var topics = _context.GetChildren().ToList(); if (_log.IsDebugEnabled) { _log.Debug($"Get topics under namespace {NamespaceName}, topics.size: {topics.Count}"); TopicsMap.ForEach(t => _log.Debug($"Get topics under namespace {NamespaceName}, topic: {t.Key}")); } var newTopics = TopicsPatternFilter(topicsFound, _topicsPattern); var oldTopics = Topics; OnTopicsAdded(TopicsListsMinus(newTopics, oldTopics)); OnTopicsRemoved(TopicsListsMinus(oldTopics, newTopics)); } catch (Exception ex) { _log.Error(ex.ToString()); } finally { _recheckPatternTimeout = _context.System.Scheduler.Advanced.ScheduleOnceCancelable(TimeSpan.FromSeconds(Math.Max(1, Conf.PatternAutoDiscoveryPeriod)), async() => { await TopicReChecker(); }); } if (_recheckPatternTimeout.IsCancellationRequested) { return; } }
private void MoveLat(int initialBearingRadians) { var newLocation = FindPointAtDistanceFrom( new GeoLocation { Latitude = _currentLatitude, Longitude = _currentLongitude }, initialBearingRadians, 2); _currentLatitude = newLocation.Latitude; // _currentLongitude = newLocation.Longitude; var mapSpan = MapSpan.FromCenterAndRadius( new Position(_currentLatitude, _currentLongitude), Distance.FromKilometers(1)); TopicsMap.MoveToRegion(mapSpan); }
async void GetCurrentLocation() { var location = await CrossGeolocator.Current.GetPositionAsync(); var mapSpan = MapSpan.FromCenterAndRadius( new Position(location.Latitude, location.Longitude), Distance.FromKilometers(1)); _currentLatitude = location.Latitude; _currentLongitude = location.Longitude; TopicsMap.MoveToRegion(mapSpan); App.MapPageViewModel.TopicsViewModel.Model.Topics = new List <string>( App.MapPageViewModel.TopicsViewModel.Topics.Where(e => !string.IsNullOrEmpty(e.TopicName)) .Select(e => e.TopicName)); App.MapPageViewModel.TopicsViewModel.Model.Coordinates = new GeoCoordinates { Latitude = _currentLatitude, Longitude = _currentLongitude }; WalkieTalkyClient client = new WalkieTalkyClient(); var token = Services.Services.GetInstance().AccountService.GetAccountFor(App.AppName).Properties["access_token"]; var response = client.CreatePutRequest(App.MapPageViewModel.TopicsViewModel.Model.PersonId, App.MapPageViewModel.TopicsViewModel.Model, token); foreach (PersonRecord personRecord in response.ClosePersons) { if (personRecord.Coordinates.Latitude == null || personRecord.Coordinates.Longitude == null || string.IsNullOrEmpty(personRecord.Name)) { continue; } var item = new Pin { Type = PinType.Generic, Position = new Position(personRecord.Coordinates.Latitude.Value, personRecord.Coordinates.Longitude.Value), Label = personRecord.Name, Address = personRecord.Phonenumber }; TopicsMap.CustomPins.Add(new CustomPin { Pin = item }); TopicsMap.Pins.Add(item); } if (response.Match != null) { string matchedTopicName = string.Empty; foreach (Topic topic in App.TopicsViewModel.Topics) { foreach (string topicName in response.Match.Topics) { if (topicName.ToUpper().Equals(topic.TopicName.ToUpper())) { matchedTopicName = topicName; } } } await Navigation.PushModalAsync(new MatchPage(response.Match, matchedTopicName)); } }