protected void HandleFoundBeacon(string beaconId, ushort major, ushort minor) { var beaconModel = new BeaconModel { UUID = beaconId, Major = major, Minor = minor }; var activity = new BeaconActivity { BeaconModel = beaconModel, CreationDate = DateTime.Now }; //If we registered a beacon in lesser period than threshold we should ignore this event var lastActivity = _beaconsActivity.LastOrDefault(x => x.BeaconModel.Equals(activity.BeaconModel) && DateTime.Now - x.CreationDate < _threshold); if (lastActivity != null) { return; } _beaconsActivity.RemoveAll(s => s.BeaconModel.Equals(activity.BeaconModel)); _beaconsActivity.Add(activity); Debug.WriteLine("Found beacon: {0}.{1} - {2}", major, minor, beaconId); BeaconFound?.Invoke(null, beaconModel); }
private void RangingBeaconsInRegion(object sender, ICollection <Beacon> beacons) { if (beacons != null && beacons.Count > 0) { var foundBeacons = beacons.ToList(); foreach (var beacon in beacons) { BeaconFound?.Invoke(this, beacon); } } }