Esempio n. 1
0
        public Boxes(Helper aHelper, EventServerUpnp aEventServer, ISsdpNotifyProvider aSsdpNotify, bool aDiscoverProxyDevices)
        {
            iLock           = new object();
            iHelper         = aHelper;
            iEventServer    = aEventServer;
            iListenerNotify = aSsdpNotify;
            iTree           = new Tree(aHelper);

            //listen to the volkano service
            iDeviceListVolkano = new DeviceListUpnp(ServiceVolkano.ServiceType(), iListenerNotify);
            iDeviceListVolkano.EventDeviceAdded   += VolkanoAddedHandler;
            iDeviceListVolkano.EventDeviceRemoved += VolkanoRemovedHandler;

            //listen to the proxy service
            if (aDiscoverProxyDevices)
            {
                iDeviceListProxy = new DeviceListUpnp(ServiceProxy.ServiceType(), iListenerNotify);
                iDeviceListProxy.EventDeviceAdded   += ProxyAddedHandler;
                iDeviceListProxy.EventDeviceRemoved += ProxyRemovedHandler;
            }

            // Configure Service Point Manager
            ServicePointManager.DefaultConnectionLimit = 50;
            ServicePointManager.Expect100Continue      = false;
            ServicePointManager.UseNagleAlgorithm      = false;
        }
Esempio n. 2
0
        public DeviceFinder(string aUglyName)
        {
            iUglyName = aUglyName;

            ServiceType type = ServiceVolkano.ServiceType();

            type.Version = 1;

            iListener = new SsdpListenerMulticast();

            iDeviceList = new DeviceListUpnp(type, iListener);

            iDeviceList.EventDeviceAdded += DeviceAdded;

            iSemaphore = new ManualResetEvent(false);

            iFound = false;
        }
Esempio n. 3
0
        internal BasicSetup(Device aDevice, EventServerUpnp aEventServer)
        {
            iLock = new object();
            if (aDevice.HasService(ServiceConfiguration.ServiceType(1)) > 0)
            {
                iServiceConfiguration = new ServiceConfiguration(aDevice, aEventServer);
                iServiceConfiguration.EventInitial += EventHandlerConfigurationInitial;
                iActionSetParameter             = iServiceConfiguration.CreateAsyncActionSetParameter();
                iActionSetParameter.EventError += SetParameterError;
            }

            if (aDevice.HasService(ServiceVolkano.ServiceType(1)) > 0)
            {
                iServiceVolkano = new ServiceVolkano(aDevice);
                iActionReboot   = iServiceVolkano.CreateAsyncActionReboot();
            }
            iDeviceIpAddress = aDevice.IpAddress;
        }
Esempio n. 4
0
        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);
        }