public void Stop() { // Call stop on the publisher and expect the status changed callback if (_publisher != null && (_publisher.Status == WiFiDirectAdvertisementPublisherStatus.Created || _publisher.Status == WiFiDirectAdvertisementPublisherStatus.Started)) { _publisher.Stop(); } else { _listener.OnAdvertisementStopped("Advertisement status is null or bad status"); } }
public void Stop() { if (_active) { _publisher.Stop(); } }
public void Stop() { if (_publisher.Status == WiFiDirectAdvertisementPublisherStatus.Started) { _publisher.Stop(); } }
// Stop advertizing public void Dispose() { if (publisher != null) { publisher.Stop(); } }
private static void DisposeWiFiPublisher() { wifiPublisher.Stop(); wifiPublisher.StatusChanged -= WifiPublisher_StatusChanged; wifiPublisher = null; wifiConnectionListener.ConnectionRequested -= WifiConnectionListener_ConnectionRequested; wifiConnectionListener = null; }
private void StopAdvertisement() { _publisher.Stop(); _publisher.StatusChanged -= OnStatusChanged; _listener.ConnectionRequested -= OnConnectionRequested; connectionSettingsPanel.Reset(); _informationElements.Clear(); btnStartAdvertisement.IsEnabled = true; btnStopAdvertisement.IsEnabled = false; }
private void btnWatcher_Click(object sender, RoutedEventArgs e) { if (_fWatcherStarted == false) { _publisher.Start(); if (_publisher.Status != WiFiDirectAdvertisementPublisherStatus.Started) { rootPage.NotifyUser("Failed to start advertisement.", NotifyType.ErrorMessage); return; } DiscoveredDevices.Clear(); rootPage.NotifyUser("Finding Devices...", NotifyType.StatusMessage); String deviceSelector = WiFiDirectDevice.GetDeviceSelector( Utils.GetSelectedItemTag <WiFiDirectDeviceSelectorType>(cmbDeviceSelector)); _deviceWatcher = DeviceInformation.CreateWatcher(deviceSelector, new string[] { "System.Devices.WiFiDirect.InformationElements" }); _deviceWatcher.Added += OnDeviceAdded; _deviceWatcher.Removed += OnDeviceRemoved; _deviceWatcher.Updated += OnDeviceUpdated; _deviceWatcher.EnumerationCompleted += OnEnumerationCompleted; _deviceWatcher.Stopped += OnStopped; _deviceWatcher.Start(); btnWatcher.Content = "Stop Watcher"; _fWatcherStarted = true; } else { _publisher.Stop(); btnWatcher.Content = "Start Watcher"; _fWatcherStarted = false; _deviceWatcher.Added -= OnDeviceAdded; _deviceWatcher.Removed -= OnDeviceRemoved; _deviceWatcher.Updated -= OnDeviceUpdated; _deviceWatcher.EnumerationCompleted -= OnEnumerationCompleted; _deviceWatcher.Stopped -= OnStopped; _deviceWatcher.Stop(); rootPage.NotifyUser("Device watcher stopped.", NotifyType.StatusMessage); } }
public void StopScan() { _scanning = false; _publisher.Stop(); _deviceWatcher.Added -= OnDeviceAdded; _deviceWatcher.Removed -= OnDeviceRemoved; _deviceWatcher.Updated -= OnDeviceUpdated; _deviceWatcher.EnumerationCompleted -= OnEnumerationCompleted; _deviceWatcher.Stopped -= OnStopped; _deviceWatcher.Stop(); LastErrorMessage = "Device watcher stopped."; }
private void btnStopAdvertisement_Click(object sender, RoutedEventArgs e) { try { if (_publisher != null) { _publisher.Stop(); _publisher.StatusChanged -= OnStatusChanged; rootPage.NotifyUser("Advertisement stopped successfully", NotifyType.StatusMessage); } if (_listener != null) { _listener.ConnectionRequested -= OnConnectionRequested; } } catch (Exception ex) { rootPage.NotifyUser("Error stopping Advertisement: " + ex.ToString(), NotifyType.ErrorMessage); } }
private async void SetupWifiDirect() { ListenForIncomingConnections(); if (_fWatcherStarted == false) { _publisher.Advertisement.ListenStateDiscoverability = WiFiDirectAdvertisementListenStateDiscoverability.Normal; //make this device known _publisher.Start(); if (_publisher.Status != WiFiDirectAdvertisementPublisherStatus.Started) { NotifyUser("Failed to start advertisement.", NotifyType.ErrorMessage); return; } //detect other devices DiscoveredDevices.Clear(); NotifyUser("Finding Devices...", NotifyType.StatusMessage); String deviceSelector = WiFiDirectDevice.GetDeviceSelector(WiFiDirectDeviceSelectorType.AssociationEndpoint);//WiFiDirectDevice.GetDeviceSelector( //Utils.GetSelectedItemTag<WiFiDirectDeviceSelectorType>(cmbDeviceSelector)); _deviceWatcher = DeviceInformation.CreateWatcher(deviceSelector, new string[] { "System.Devices.WiFiDirect.InformationElements" }); _deviceWatcher.Added += OnDeviceAdded; _deviceWatcher.Removed += OnDeviceRemoved; _deviceWatcher.Updated += OnDeviceUpdated; _deviceWatcher.EnumerationCompleted += OnEnumerationCompleted; _deviceWatcher.Stopped += OnStopped; _deviceWatcher.Start(); //btnWatcher.Content = "Stop Watcher"; _fWatcherStarted = true; } else { _publisher.Stop(); //btnWatcher.Content = "Start Watcher"; _fWatcherStarted = false; _deviceWatcher.Added -= OnDeviceAdded; _deviceWatcher.Removed -= OnDeviceRemoved; _deviceWatcher.Updated -= OnDeviceUpdated; _deviceWatcher.EnumerationCompleted -= OnEnumerationCompleted; _deviceWatcher.Stopped -= OnStopped; _deviceWatcher.Stop(); NotifyUser("Device watcher stopped.", NotifyType.StatusMessage); } string ServiceSelector = WiFiDirectService.GetSelector("WalkieTalkie"); // Get all WiFiDirect services that are advertising and in range //DeviceInformationCollection devInfoCollection = await DeviceInformation.FindAllAsync(ServiceSelector); //// Get a Service Seeker object //WiFiDirectService Service = await WiFiDirectService.FromIdAsync(devInfoCollection[0].Id); //// Connect to the Advertiser //WiFiDirectServiceSession Session = await Service.ConnectAsync(); //// Get the local and remote IP addresses //var EndpointPairs = Session.GetConnectionEndpointPairs(); }
private void Button_StopAdvertising_Click(object sender, RoutedEventArgs e) { publisher.Stop(); }