当前位置: 首页>>代码示例>>C#>>正文


C# UPnP.UPnPDevice类代码示例

本文整理汇总了C#中OpenSource.UPnP.UPnPDevice的典型用法代码示例。如果您正苦于以下问题:C# UPnPDevice类的具体用法?C# UPnPDevice怎么用?C# UPnPDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UPnPDevice类属于OpenSource.UPnP命名空间,在下文中一共展示了UPnPDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateTableOfServiceNames

 public static Hashtable CreateTableOfServiceNames(UPnPDevice rootDevice)
 {
     Hashtable RetVal = new Hashtable();
     foreach (UPnPDevice d in rootDevice.EmbeddedDevices) { ProcessDevice(d, RetVal); }
     foreach (UPnPService s in rootDevice.Services) { ProcessService(s, RetVal); }
     return (RetVal);
 }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:7,代码来源:SourceCodeRepository.cs

示例2: Gatekeeper

        public Gatekeeper(int PortNumber)
        {
            A_ICB = new UPnPService.UPnPServiceInvokeHandler(A_InvokeSink);
            A_IECB = new UPnPService.UPnPServiceInvokeErrorHandler(A_InvokeErrorSink);

            Port = PortNumber;
            Root = UPnPDevice.CreateRootDevice(1000,1,"");
            Root.FriendlyName = "UPnPShare";

            Root.StandardDeviceType = "UPnPGateKeeper";
            DV = new DvGateKeeper();
            Root.AddService(DV);

            DV.External_Register = new DvGateKeeper.Delegate_Register(RegisterSink);
            DV.External_UnRegister = new DvGateKeeper.Delegate_UnRegister(UnRegisterSink);
            DV.External_GetDocument = new DvGateKeeper.Delegate_GetDocument(GetDocumentSink);
            DV.External_AddDevice = new DvGateKeeper.Delegate_AddDevice(AddDeviceSink);
            DV.External_RemoveDevice = new DvGateKeeper.Delegate_RemoveDevice(RemovedDeviceSink);
            DV.External_FireEvent = new DvGateKeeper.Delegate_FireEvent(FireEventSink);
            DV.External_GetStateTable = new DvGateKeeper.Delegate_GetStateTable(GetStateTableSink);

            DV.External_Invoke = new DvGateKeeper.Delegate_Invoke(InvokeSink);
            DV.External_InvokeAsync = new DvGateKeeper.Delegate_InvokeAsync(InvokeAsyncSink);
            DV.External_InvokeAsyncResponse = new DvGateKeeper.Delegate_InvokeAsyncResponse(InvokeAsyncResponseSink);

            (new UPnPDebugObject(Root)).SetField("NoSSDP",true);

            Root.StartDevice(PortNumber);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:29,代码来源:Gatekeeper.cs

示例3: AddSink

        private static void AddSink(DimmableLightDiscovery sender, UPnPDevice d)
        {
            Console.WriteLine("Added Device: " + d.FriendlyName);

            // To interface with a service, instantiate the appropriate wrapper class on the appropriate service
            // Traverse the device heirarchy to the correct device, and invoke 'GetServices', passing in the static field 'SERVICE_NAME'
            // of the appropriate wrapper class. This method returns an array of all services with this service type. For most purposes,
            // there will only be one service, in which case you can use array index 0.
            // Save a reference to this instance of the wrapper class for later use.

            CpDimming Dimming = new CpDimming(d.GetServices(CpDimming.SERVICE_NAME)[0]);

            sw = new CpSwitchPower(d.GetServices(CpSwitchPower.SERVICE_NAME)[0]);

            // To subscribe to Events, call the '_subscribe' method of the wrapper class. The only parameter is
            // the duration of the event. A good value is 300 seconds.
            //Dimming._subscribe(300);

            // The wrapper class exposes all the evented state variables through events in the form 'OnStateVariable_xx', where xx is the variable name.

            // The wrapper class exposes methods in two formats. Asyncronous and Syncronous. The Async method calls are exposed simply
            // by the name of the method. The Syncronous version is the same, except with the word, 'Sync_' prepended to the name.
            // Asyncronous responses to th async method calls are dispatched through the event in the format, 'OnResult_x' where x is the method name.

            // Note: All arguments are automatically type checked. Allowed Values are abstracted through enumerations, that are defined in the wrapper class.
            // To access the list of allowed values or ranges for a given device, refer to the property 'Values_XXX' for a list of the allowed values for a
            // given state variable. Similarly, refer to the properties 'HasMaximum_XXX', 'HasMinimum_XXX', 'Maximum_XXX', and 'Minimum_XXX' where XXX is the variable name, for the Max/Min values.

            // To determine if a given service implements a particular StateVariable or Method, use the properties, 'HasStateVariableXXX' and 'HasActionXXX' where XXX is the method/variable name.
        }
开发者ID:GufCab,项目名称:Semester-Projekt---Test-Kode,代码行数:30,代码来源:Main.cs

示例4: Generate

        public override bool Generate(UPnPDevice[] devices, DirectoryInfo outputDirectory)
        {
            bool ok = false;
            bool RetVal = false;
            foreach (UPnPDevice device in devices)
            {
                if (((ServiceGenerator.Configuration)device.User).ConfigType == ServiceGenerator.ConfigurationType.CONTROLPOINT)
                {
                    ok = true;
                    if (Configuration.UPNP_1dot1)
                    {
                        device.ArchitectureVersion = "1.1";
                    }
                    else
                    {
                        device.ArchitectureVersion = "1.0";
                    }

                    device.ClearCustomFieldsInDescription();
                    ((ServiceGenerator.Configuration)device.User).AddAllCustomFieldsToDevice(device);

                    RetVal = GenerateEx(device, outputDirectory, GetServiceNameTable(device));
                    if (!RetVal) { break; }
                }
            }
            return (ok ? RetVal : true);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:27,代码来源:CPDotNetGenerator.cs

示例5: OnDeviceAdded

		private void OnDeviceAdded(UPnPSmartControlPoint cp, UPnPDevice device)
		{
			Console.WriteLine("found player " + device);
			//players.Add(new SonosPlayer(device));
			// we need to save these for future reference
			lock (playerDevices)
			{
				playerDevices[device.UniqueDeviceName] = device;
			}

			// okay, we will try and notify the players that they have been found now.
			var player = players.FirstOrDefault(p => p.UUID == device.UniqueDeviceName);
			if (player != null)
			{
				player.SetDevice(device);
			}

			// Subscribe to events
			var topologyService = device.GetService("urn:upnp-org:serviceId:ZoneGroupTopology");
			topologyService.Subscribe(600, (service, subscribeok) =>
				{
					if (!subscribeok) return;

					var stateVariable = service.GetStateVariableObject("ZoneGroupState");
					stateVariable.OnModified += OnZoneGroupStateChanged;
				});
		}
开发者ID:ksjoberg,项目名称:Jishi.Intel.SonosUPnP,代码行数:27,代码来源:SonosDiscovery.cs

示例6: CpMediaServer

        /// <summary>
        /// Creates a programmer-friendly object for using a device
        /// that happens implement a MediaServer.
        /// </summary>
        /// <param name="device"></param>
        public CpMediaServer(UPnPDevice device)
        {
            UPnPService sCM = device.GetServices(CpConnectionManager.SERVICE_NAME)[0];
            UPnPService sCD = device.GetServices(CpContentDirectory.SERVICE_NAME)[0];

            CpConnectionManager cpCM = new CpConnectionManager(sCM);
            CpContentDirectory cpCD = new CpContentDirectory(sCD);

            UDN = device.UniqueDeviceName;

            if (
                (cpCD.HasAction_GetSearchCapabilities == false) ||
                (cpCD.HasAction_GetSortCapabilities == false) ||
                (cpCD.HasAction_GetSystemUpdateID == false) ||
                (cpCD.HasAction_Browse == false)
                )
            {
                throw new UPnPCustomException(0, "MediaServer does not implement minimum features.");
            }

            this.m_ConnectionManager = cpCM;
            this.m_ContentDirectory = cpCD;

            //create a virtualized root container with the desired settings
            m_Root = new CpRootContainer(this);
            m_Root.UDN = device.UniqueDeviceName;
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:32,代码来源:CpMediaServer.cs

示例7: UPnPDeviceHostServiceProxy

        public UPnPDeviceHostServiceProxy(Assembly assembly)
        {
            this.Name = Environment.MachineName + ":" + assembly.FullName.Split(',').First();
            this.Namespace = assembly.FullName;
            var regex = new Regex("Version=(.\\..)");
            var version = regex.Match(this.Namespace).Groups[1].Value;
            this.Version = double.Parse(version);

            _device = UPnPDevice.CreateRootDevice(int.MaxValue, this.Version, "\\");
            _device.FriendlyName = this.Name;
            _device.DeviceURN = this.Namespace;
            _device.HasPresentation = false;

            var types = (from type in assembly.GetTypes()
                         let ifs = type.GetInterfaces().Where(t => t.GetCustomAttributes<ServiceContractAttribute>().Count() > 0).First()
                         select new { Type = type, Interface = ifs }).ToList();

            List<IUPnPService> services = new List<IUPnPService>();
            foreach (var tc in types)
            {
                var service = new UPnPServiceProxy(tc.Type, tc.Interface);
                services.Add(service);
                _device.AddService(service);
            }

            this.Services = services.ToList();
            _device = this.GetUPnPDevice();
        }
开发者ID:evisar,项目名称:upnp-poc,代码行数:28,代码来源:UPnPDeviceHostServiceProxy.cs

示例8: BuildDeviceDescriptionStreamer

        public static string BuildDeviceDescriptionStreamer(UPnPDevice d, string templateString)
        {
            string WS = BuildDeviceDescriptionStreamer_EmbeddedDevice(d,"",SourceCodeRepository.GetTextBetweenTags(templateString,"//{{{DEVICE_BEGIN}}}","//{{{DEVICE_END}}}"));

            templateString = SourceCodeRepository.InsertTextBeforeTag(templateString,"//{{{DEVICE_BEGIN}}}",WS);
            templateString = SourceCodeRepository.RemoveAndClearTag("//{{{DEVICE_BEGIN}}}","//{{{DEVICE_END}}}",templateString);
            return(templateString);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:8,代码来源:DeviceObjectGenerator.cs

示例9: ForceDisposeDevice

 public void ForceDisposeDevice(UPnPDevice root)
 {
     while (root.ParentDevice != null)
     {
         root = root.ParentDevice;
     }
     iSCP.SSDPNotifySink(null, null, null, false, root.UniqueDeviceName, "upnp:rootdevice", 0, null);
 }
开发者ID:Scannow,项目名称:SWYH,代码行数:8,代码来源:UPnPSmartControlPoint.cs

示例10: GenerateStateVariableLookupTable

 public static void GenerateStateVariableLookupTable(UPnPDevice d, Hashtable t)
 {
     foreach(UPnPDevice ed in d.EmbeddedDevices)
     {
         GenerateStateVariableLookupTable(ed,t);
     }
     foreach(UPnPService s in d.Services)
     {
         GenerateStateVariableLookupTable_Service(s,t);
     }
 }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:11,代码来源:DeviceObjectGenerator.cs

示例11: ForceDisposeDevice

 public void ForceDisposeDevice(UPnPDevice dev)
 {
     if (dev.ParentDevice != null)
     {
         ForceDisposeDevice(dev.ParentDevice);
     }
     else
     {
         scp.ForceDisposeDevice(dev);
     }
 }
开发者ID:GufCab,项目名称:Semester-Projekt---PC-Program,代码行数:11,代码来源:MediaRendererDiscovery.cs

示例12: ModifyDevice

        public ModifyDevice(UPnPDevice d)
        {
            OriginalDevice = d;
            NewDevice = OriginalDevice;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            ShowDevice(d);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:11,代码来源:ModifyDevice.cs

示例13: AddSink

        /// <summary>
        /// Eventfunction that is run when an UPnP sink is detected on the network. Only accepts sinks with the friendly name: "HiPi - Sink". 
        /// If it has the right name then it creates three stacks (AVTransport, ConnectionManager and RenderingControl)
        /// </summary>
        /// <param name="sender">The object that send the event</param>
        /// <param name="d">The discovered sink device</param>
        private void AddSink(MediaRendererDiscovery sender, UPnPDevice d)
        {
            Console.WriteLine("Added Sink Device: " + d.FriendlyName);
            if (d.FriendlyName == "HiPi - Sink")
            {
                UPnP_SinkFunctions func = new UPnP_SinkFunctions(
                    new SinkStack.CpAVTransport(d.GetServices(SinkStack.CpAVTransport.SERVICE_NAME)[0]),
                    new SinkStack.CpConnectionManager(d.GetServices(SinkStack.CpConnectionManager.SERVICE_NAME)[0]),
                    new SinkStack.CpRenderingControl(d.GetServices(SinkStack.CpRenderingControl.SERVICE_NAME)[0]));

                AddSinkEvent(func, null);
            }
        }
开发者ID:GufCab,项目名称:Semester-Projekt---Test-Kode,代码行数:19,代码来源:UPnP_Setup.cs

示例14: GetCDS

        public CpContentDirectory GetCDS(UPnPDevice device)
        {
            UPnPDevice d = device;

            UPnPService[] services = d.GetServices(CpContentDirectory.SERVICE_NAME);

            if (services == null || services.Length == 0)
            {
                return null;
            }

            return new CpContentDirectory(services[0]);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:13,代码来源:CdsSubTest.cs

示例15: Start

 public override void Start(UPnPDevice device)
 {
     if (ScriptorInterface != null)
     {
         Reset();
         ScriptorInterface.SetUPnPDevice(device);
         ScriptorInterface.Execute();
         for (int i=0; i<states.Length; i++)
         {
             if (state < states[i])
                 state = states[i];
         }
     }
 }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:14,代码来源:DeviceScriptorTest.cs


注:本文中的OpenSource.UPnP.UPnPDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。