Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. public static class FindUDPBroadcast
  2. {
  3. private static readonly ObservableCollection<BeaconLocation> beaconsList = new ObservableCollection<BeaconLocation>();
  4. private static Probe probe;
  5. public static bool _foundServer = false;
  6.  
  7. public static void ForServer()
  8. {
  9. probe = new Probe("myBeacon");
  10. probe.BeaconsUpdated += locations => Application.Current.Dispatcher.BeginInvoke((Action)(() => ReplaceBeaconsList(locations)));
  11. probe.Start();
  12. beaconsList.CollectionChanged += OnBindingListChanged;
  13.  
  14. }
  15.  
  16. private static void ReplaceBeaconsList(IEnumerable<BeaconLocation> beacons)
  17. {
  18. beaconsList.Synchronise(beacons);
  19. }
  20.  
  21. private static void OnBindingListChanged(object sender, NotifyCollectionChangedEventArgs e)
  22. {
  23. var _serverData = beaconsList[0].Data.Split(':');
  24. int _tcp = int.Parse(_serverData[0]);
  25. int _udp = int.Parse(_serverData[1]);
  26. _foundServer = MakeMe.ConfigFile(beaconsList[0].Address.Address.ToString(), Dns.GetHostEntry(beaconsList[0].Address.Address.ToString()).HostName, beaconsList[0].Address.Port,_tcp , _udp);
  27. probe.Dispose();
  28.  
  29. }
  30.  
  31. }
  32.  
  33. public AuthenticationViewModel(IAuthenticationService authenticationService)
  34. {
  35. FindUDPBroadcast.ForServer();
  36. _authenticationService = authenticationService;
  37. _loginCommand = new AnotherCommandImplementation(Login, CanLogin);
  38. _logoutCommand = new AnotherCommandImplementation(Logout, CanLogout);
  39. _showViewCommand = new AnotherCommandImplementation(ShowView, null);
  40. FirstBoot = IsThisFirstBoot();
  41. if (FirstBoot)
  42. {
  43. FirstBootSetup();
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement