Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class FindUDPBroadcast
- {
- private static readonly ObservableCollection<BeaconLocation> beaconsList = new ObservableCollection<BeaconLocation>();
- private static Probe probe;
- public static bool _foundServer = false;
- public static void ForServer()
- {
- probe = new Probe("myBeacon");
- probe.BeaconsUpdated += locations => Application.Current.Dispatcher.BeginInvoke((Action)(() => ReplaceBeaconsList(locations)));
- probe.Start();
- beaconsList.CollectionChanged += OnBindingListChanged;
- }
- private static void ReplaceBeaconsList(IEnumerable<BeaconLocation> beacons)
- {
- beaconsList.Synchronise(beacons);
- }
- private static void OnBindingListChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- var _serverData = beaconsList[0].Data.Split(':');
- int _tcp = int.Parse(_serverData[0]);
- int _udp = int.Parse(_serverData[1]);
- _foundServer = MakeMe.ConfigFile(beaconsList[0].Address.Address.ToString(), Dns.GetHostEntry(beaconsList[0].Address.Address.ToString()).HostName, beaconsList[0].Address.Port,_tcp , _udp);
- probe.Dispose();
- }
- }
- public AuthenticationViewModel(IAuthenticationService authenticationService)
- {
- FindUDPBroadcast.ForServer();
- _authenticationService = authenticationService;
- _loginCommand = new AnotherCommandImplementation(Login, CanLogin);
- _logoutCommand = new AnotherCommandImplementation(Logout, CanLogout);
- _showViewCommand = new AnotherCommandImplementation(ShowView, null);
- FirstBoot = IsThisFirstBoot();
- if (FirstBoot)
- {
- FirstBootSetup();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement