private void FormDevices_Load(object sender, EventArgs e) { try { // create discovery system iListenerNotify = new SsdpListenerMulticast(); // create device lists iDeviceListJukebox = new DeviceListUpnp(ServiceJukebox.ServiceType(1), iListenerNotify); // hook in to discovery events iDeviceListJukebox.EventDeviceAdded += DeviceAlive; iDeviceListJukebox.EventDeviceRemoved += DeviceByeBye; NetworkInfoModel iface = iHelper.Interface.Interface.Info; if (iface != null) { // start discovery process iListenerNotify.Start(iface.IPAddress); iDeviceListJukebox.Start(iface.IPAddress); // improve discovery process iDeviceListJukebox.Rescan(); } else { DiscoveryFailed("Device discovery failed: no valid network interface card selected"); } } catch (Linn.Network.NetworkError ne) { DiscoveryFailed("NetworkError on device discovery: " + ne.Message); } catch (Exception exc) { DiscoveryFailed("Error on device discovery: " + exc.Message); } }
public Device Find(IPAddress aInterface, int aTimeout) // in milliseconds { Trace.WriteLine(Trace.kTopology, "DeviceFinder Find: " + iUglyName); iListener.Start(aInterface); iDeviceList.Start(aInterface); iSemaphore.WaitOne(aTimeout, false); Trace.WriteLine(Trace.kTopology, "DeviceFinder Found: " + iUglyName); iDeviceList.Stop(); iListener.Stop(); if (iFound) { return(iDevice); } throw (new DeviceFinderException()); }
public bool FindDevice() { iIsFound.Reset(); iDeviceList = new DeviceListUpnp(ServiceVolkano.ServiceType(), iListener); iDeviceList.EventDeviceAdded += DeviceAdded; iDeviceList.Start(iInterface); bool result = false; uint i = kMaxFindRetries; while (i-- > 0) { iConsole.Write("Finding " + iUglyName + " ................ "); if (WaitFor(iIsFound, kMaxFindSeconds)) { result = true; break; } if (i > 0) { iConsole.Write("Retry"); iConsole.Newline(); iDeviceList.Rescan(); } } iDeviceList.EventDeviceAdded -= DeviceAdded; iDeviceList.Stop(); return(result); }
void IStack.Start(IPAddress aIpAddress) { iListenerNotify.Start(aIpAddress); iDeviceListProduct.Start(aIpAddress); }