예제 #1
0
        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);
            }
        }