Example #1
0
 public bool Connect()
 {
     if (_contropoint == null)
     {
         _contropoint = new UpnpSmartControlPoint();
         _contropoint.OnAddedDevice += _contropoint_OnAddedDevice;
         _isconnected = true;
     }
     return(true);
 }
Example #2
0
        private void controPoint_OnAddedDevice(UpnpSmartControlPoint sender, UPnPDevice device)
        {
            if (String.IsNullOrWhiteSpace(device.StandardDeviceType))
            {
                return;
            }

            //foreach (UPnPService s in device.Services)
            //{
            //    s.Subscribe(1000, new UPnPService.UPnPEventSubscribeHandler(_subscribe_sink));
            //}

            lock (deviceOperationLock)
            {
                InterfaceModule module = new InterfaceModule();
                module.Domain      = this.Domain;
                module.Address     = device.UniqueDeviceName;
                module.Description = device.FriendlyName + " (" + device.ModelName + ")";
                if (device.StandardDeviceType == "MediaRenderer")
                {
                    module.ModuleType = MIG.ModuleTypes.MediaReceiver;
                }
                else if (device.StandardDeviceType == "MediaServer")
                {
                    module.ModuleType = MIG.ModuleTypes.MediaTransmitter;
                }
                else if (device.StandardDeviceType == "SwitchPower")
                {
                    module.ModuleType = MIG.ModuleTypes.Switch;
                }
                else if (device.StandardDeviceType == "BinaryLight")
                {
                    module.ModuleType = MIG.ModuleTypes.Light;
                }
                else if (device.StandardDeviceType == "DimmableLight")
                {
                    module.ModuleType = MIG.ModuleTypes.Dimmer;
                }
                else
                {
                    module.ModuleType = MIG.ModuleTypes.Sensor;
                }
                module.CustomData = new DeviceHolder()
                {
                    Device = device, Initialized = false
                };
                modules.Add(module);
                //
                OnInterfacePropertyChanged(this.GetDomain(), "1", "DLNA/UPnP Controller", "Controller.Status", "Added node " + module.Description);
            }
            OnInterfaceModulesChanged(this.GetDomain());
        }
Example #3
0
 private void controPoint_OnDeviceExpired(UpnpSmartControlPoint sender, UPnPDevice device)
 {
     lock (deviceOperationLock)
     {
         var module = modules.Find(m => m.Address == device.UniqueDeviceName);
         if (module != null)
         {
             OnInterfacePropertyChanged(this.GetDomain(), "1", "DLNA/UPnP Controller", "Controller.Status", "Removed node " + module.Description);
             modules.Remove(module);
             OnInterfaceModulesChanged(this.GetDomain());
         }
     }
 }
Example #4
0
 public bool Connect()
 {
     if (controlPoint == null)
     {
         controlPoint = new UpnpSmartControlPoint();
         controlPoint.OnAddedDevice   += controPoint_OnAddedDevice;
         controlPoint.OnRemovedDevice += controPoint_OnRemovedDevice;
         controlPoint.OnDeviceExpired += controPoint_OnDeviceExpired;
         isConnected = true;
     }
     OnInterfaceModulesChanged(this.GetDomain());
     return(true);
 }
Example #5
0
 private void _contropoint_OnAddedDevice(UpnpSmartControlPoint sender, UPnPDevice device)
 {
     if (InterfacePropertyChangedAction != null)
     {
         //foreach (UPnPService s in device.Services)
         //{
         //    s.Subscribe(1000, new UPnPService.UPnPEventSubscribeHandler(_subscribe_sink));
         //}
         InterfacePropertyChangedAction(new InterfacePropertyChangedAction()
         {
             Domain = this.Domain, SourceId = device.UniqueDeviceName, SourceType = "UPnP " + device.FriendlyName, Path = "UPnP.DeviceType", Value = device.StandardDeviceType
         });
     }
 }
Example #6
0
 public void Disconnect()
 {
     if (_localdevice != null)
     {
         _localdevice.StopDevice();
         _localdevice = null;
     }
     if (_contropoint != null)
     {
         _contropoint.OnAddedDevice -= _contropoint_OnAddedDevice;
         _contropoint = null;
     }
     _isconnected = false;
 }
Example #7
0
 public void Disconnect()
 {
     /*
      * if (localDevice != null)
      * {
      *  localDevice.StopDevice();
      *  localDevice = null;
      * }
      */
     if (controlPoint != null)
     {
         controlPoint.OnAddedDevice   -= controPoint_OnAddedDevice;
         controlPoint.OnRemovedDevice -= controPoint_OnRemovedDevice;
         controlPoint.OnDeviceExpired -= controPoint_OnDeviceExpired;
         controlPoint.ShutDown();
         controlPoint = null;
     }
     isConnected = false;
 }
Example #8
0
 private void controPoint_OnRemovedDevice(UpnpSmartControlPoint sender, UPnPDevice device)
 {
     lock (deviceOperationLock)
     {
         var module = modules.Find(m => m.Address == device.UniqueDeviceName);
         if (module != null)
         {
             if (InterfacePropertyChangedAction != null)
                 InterfacePropertyChangedAction(new InterfacePropertyChangedAction() {
                     Domain = this.Domain,
                     SourceId = "1",
                     SourceType = "DLNA/UPnP Controller",
                     Path = "Controller.Status",
                     Value = "Removed node " + module.Description
                 });
             modules.Remove(module);
             if (InterfaceModulesChangedAction != null) InterfaceModulesChangedAction(new InterfaceModulesChangedAction() { Domain = this.Domain });
         }
     }
 }
Example #9
0
        private void controPoint_OnAddedDevice(UpnpSmartControlPoint sender, UPnPDevice device)
        {
            if (String.IsNullOrWhiteSpace(device.StandardDeviceType))
                return;

            //foreach (UPnPService s in device.Services)
            //{
            //    s.Subscribe(1000, new UPnPService.UPnPEventSubscribeHandler(_subscribe_sink));
            //}

            lock (deviceOperationLock)
            {
                InterfaceModule module = new InterfaceModule();
                module.Domain = this.Domain;
                module.Address = device.UniqueDeviceName;
                module.Description = device.FriendlyName + " (" + device.ModelName + ")";
                if (device.StandardDeviceType == "MediaRenderer")
                {
                    module.ModuleType = MIG.ModuleTypes.MediaReceiver;
                }
                else if (device.StandardDeviceType == "MediaServer")
                {
                    module.ModuleType = MIG.ModuleTypes.MediaTransmitter;
                }
                else if (device.StandardDeviceType == "SwitchPower")
                {
                    module.ModuleType = MIG.ModuleTypes.Switch;
                }
                else if (device.StandardDeviceType == "BinaryLight")
                {
                    module.ModuleType = MIG.ModuleTypes.Light;
                }
                else if (device.StandardDeviceType == "DimmableLight")
                {
                    module.ModuleType = MIG.ModuleTypes.Dimmer;
                }
                else
                {
                    module.ModuleType = MIG.ModuleTypes.Sensor;
                }
                module.CustomData = new DeviceHolder() { Device = device, Initialized = false };
                modules.Add(module);
                //
                if (InterfacePropertyChangedAction != null)
                    InterfacePropertyChangedAction(new InterfacePropertyChangedAction() {
                        Domain = this.Domain,
                        SourceId = "1",
                        SourceType = "DLNA/UPnP Controller",
                        Path = "Controller.Status",
                        Value = "Added node " + module.Description
                    });
            }
            if (InterfaceModulesChangedAction != null) InterfaceModulesChangedAction(new InterfaceModulesChangedAction() { Domain = this.Domain });
        }
Example #10
0
 public void Disconnect()
 {
     /*
     if (localDevice != null)
     {
         localDevice.StopDevice();
         localDevice = null;
     }
     */
     if (controlPoint != null)
     {
         controlPoint.OnAddedDevice -= controPoint_OnAddedDevice;
         controlPoint.OnRemovedDevice -= controPoint_OnRemovedDevice;
         controlPoint.OnDeviceExpired -= controPoint_OnDeviceExpired;
         controlPoint.ShutDown();
         controlPoint = null;
     }
     isConnected = false;
 }
Example #11
0
 public bool Connect()
 {
     if (controlPoint == null)
     {
         controlPoint = new UpnpSmartControlPoint();
         controlPoint.OnAddedDevice += controPoint_OnAddedDevice;
         controlPoint.OnRemovedDevice += controPoint_OnRemovedDevice;
         controlPoint.OnDeviceExpired += controPoint_OnDeviceExpired;
         isConnected = true;
     }
     if (InterfaceModulesChangedAction != null) InterfaceModulesChangedAction(new InterfaceModulesChangedAction() { Domain = this.Domain });
     return true;
 }
Example #12
0
 public bool Connect()
 {
     if (controPoint == null)
     {
         controPoint = new UpnpSmartControlPoint();
         controPoint.OnAddedDevice += controPoint_OnAddedDevice;
         isConnected = true;
     }
     return true;
 }
Example #13
0
 private void controPoint_OnAddedDevice(UpnpSmartControlPoint sender, UPnPDevice device)
 {
     if (InterfacePropertyChangedAction != null)
     {
         //foreach (UPnPService s in device.Services)
         //{
         //    s.Subscribe(1000, new UPnPService.UPnPEventSubscribeHandler(_subscribe_sink));
         //}
         InterfacePropertyChangedAction(new InterfacePropertyChangedAction() { Domain = this.Domain, SourceId = device.UniqueDeviceName, SourceType = "UPnP " + device.FriendlyName, Path = "UPnP.DeviceType", Value = device.StandardDeviceType });
     }
 }
Example #14
0
 public void Disconnect()
 {
     if (localDevice != null)
     {
         localDevice.StopDevice();
         localDevice = null;
     }
     if (controPoint != null)
     {
         controPoint.OnAddedDevice -= controPoint_OnAddedDevice;
         controPoint = null;
     }
     isConnected = false;
 }
Example #15
0
 private void controPoint_OnRemovedDevice(UpnpSmartControlPoint sender, UPnPDevice device)
 {
     lock (deviceOperationLock)
     {
         var module = modules.Find(m => m.Address == device.UniqueDeviceName);
         if (module != null)
         {
             OnInterfacePropertyChanged(this.GetDomain(), "1", "DLNA/UPnP Controller", "Controller.Status", "Removed node " + module.Description);
             modules.Remove(module);
             OnInterfaceModulesChanged(this.GetDomain());
         }
     }
 }
Example #16
0
 public bool Connect()
 {
     if (controlPoint == null)
     {
         controlPoint = new UpnpSmartControlPoint();
         controlPoint.OnAddedDevice += controPoint_OnAddedDevice;
         controlPoint.OnRemovedDevice += controPoint_OnRemovedDevice;
         controlPoint.OnDeviceExpired += controPoint_OnDeviceExpired;
         isConnected = true;
     }
     OnInterfaceModulesChanged(this.GetDomain());
     return true;
 }