Beispiel #1
0
        public UpnpDevice()
        {
            this.server = new UpnpServer(this);

            this.asyncStartDel = new Action(Start);
            this.asyncStopDel = new Action(Stop);
        }
Beispiel #2
0
        public UpnpDevice()
        {
            this.server = new UpnpServer(this);

            this.asyncStartDel = new Action(Start);
            this.asyncStopDel  = new Action(Stop);
        }
Beispiel #3
0
 public SsdpServer(UpnpServer upnpServer)
 {
     this.upnpServer = upnpServer;
 }
Beispiel #4
0
 public SsdpServer(UpnpServer upnpServer)
 {
     this.upnpServer = upnpServer;
 }
Beispiel #5
0
        public UpnpService(UpnpServer server, string serviceType, string serviceId, string controlUrl, string eventSubUrl, string SCPDURL)
        {
            this.server = server;

            this.serviceType = serviceType;
            this.serviceId = serviceId;
            this.controlUrl = controlUrl;
            this.eventSubUrl = eventSubUrl;
            this.SCPDURL = SCPDURL;

            MemoryStream memStream = new MemoryStream();
            using (XmlTextWriter descWriter = new XmlTextWriter(memStream, new UTF8Encoding(false)))
            {
                descWriter.Formatting = Formatting.Indented;
                descWriter.WriteRaw("<?xml version=\"1.0\"?>");

                descWriter.WriteStartElement("scpd", "urn:schemas-upnp-org:service-1-0");

                descWriter.WriteStartElement("specVersion");
                descWriter.WriteElementString("major", "1");
                descWriter.WriteElementString("minor", "0");
                descWriter.WriteEndElement();

                descWriter.WriteStartElement("actionList");

                MethodInfo[] methods = GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic);
                foreach (MethodInfo method in methods)
                {
                    //IEnumerable<UpnpServiceArgument> methAttribs = method.GetCustomAttributes(typeof(UpnpServiceArgument), true).Cast<UpnpServiceArgument>();
                    //ParameterInfo[] parameters = method.GetParameters();

                    //if (methAttribs.Count() > 0 || parameters.Any(a => a.GetCustomAttributes(typeof(UpnpServiceArgument), true).Length > 0))
                    //{
                    //    descWriter.WriteStartElement("action");
                    //    descWriter.WriteElementString("name", method.Name);
                    //    descWriter.WriteStartElement("argumentList");

                    //    //Zapisanie vstupnych parametrov
                    //    foreach (ParameterInfo parameter in parameters)
                    //    {
                    //        //UpnpServiceArgument paramAttrib = parameter.GetCustomAttributes(typeof(UpnpServiceArgument), true).FirstOrDefault() as UpnpServiceArgument;
                    //        //if (paramAttrib != null)
                    //        //{
                    //        //    descWriter.WriteStartElement("argument");
                    //        //    descWriter.WriteElementString("name", parameter.Name);
                    //        //    descWriter.WriteElementString("direction", "in");
                    //        //    descWriter.WriteElementString("relatedStateVariable", paramAttrib.RelatedStateVariable);
                    //        //    descWriter.WriteEndElement();
                    //        //}
                    //    }

                    //    //Zapisanie vystupnych parametrov
                    //    //foreach (UpnpServiceArgument methAttrib in methAttribs.OrderBy(a => a.Index))
                    //    //{
                    //    //    descWriter.WriteStartElement("argument");
                    //    //    descWriter.WriteElementString("name", methAttrib.Name);
                    //    //    descWriter.WriteElementString("direction", "out");
                    //    //    descWriter.WriteElementString("relatedStateVariable", methAttrib.RelatedStateVariable);
                    //    //    descWriter.WriteEndElement();
                    //    //}

                    //    descWriter.WriteEndElement();
                    //    descWriter.WriteEndElement();
                    //}
                }

                descWriter.WriteEndElement();
                descWriter.WriteStartElement("serviceStateTable");

                //Zapisanie premennych
                //foreach (UpnpServiceVariable variable in GetType().GetCustomAttributes(typeof(UpnpServiceVariable), true).Cast<UpnpServiceVariable>())
                //{
                //    descWriter.WriteStartElement("stateVariable");
                //    descWriter.WriteAttributeString("sendEvents", variable.SendEvents ? "yes" : "no");
                //    descWriter.WriteElementString("name", variable.Name);
                //    descWriter.WriteElementString("dataType", variable.DataType);
                //    if (variable.AllowedValue.Length > 0)
                //    {
                //        descWriter.WriteStartElement("allowedValueList");
                //        foreach (string value in variable.AllowedValue)
                //            descWriter.WriteElementString("allowedValue", value);
                //        descWriter.WriteEndElement();
                //    }
                //    descWriter.WriteEndElement();
                //}

                descWriter.WriteEndElement();

                descWriter.WriteEndElement();

                descWriter.Flush();
                this.descArray = memStream.ToArray();
            }

            //server.HttpServer.AddRoute("GET", SCPDURL, new HttpRouteDelegate(GetDescription));
            //server.HttpServer.AddRoute("POST", controlUrl, new HttpRouteDelegate(ProceedControl));
            //server.HttpServer.AddRoute("SUBSCRIBE", eventSubUrl, new HttpRouteDelegate(ProceedEventSub));
            //server.HttpServer.AddRoute("UNSUBSCRIBE", eventSubUrl, new HttpRouteDelegate(ProceedEventUnsub));
        }
Beispiel #6
0
        public UpnpService(UpnpServer server, string serviceType, string serviceId, string controlUrl, string eventSubUrl, string SCPDURL)
        {
            this.server = server;

            this.serviceType = serviceType;
            this.serviceId   = serviceId;
            this.controlUrl  = controlUrl;
            this.eventSubUrl = eventSubUrl;
            this.SCPDURL     = SCPDURL;

            MemoryStream memStream = new MemoryStream();

            using (XmlTextWriter descWriter = new XmlTextWriter(memStream, new UTF8Encoding(false)))
            {
                descWriter.Formatting = Formatting.Indented;
                descWriter.WriteRaw("<?xml version=\"1.0\"?>");

                descWriter.WriteStartElement("scpd", "urn:schemas-upnp-org:service-1-0");

                descWriter.WriteStartElement("specVersion");
                descWriter.WriteElementString("major", "1");
                descWriter.WriteElementString("minor", "0");
                descWriter.WriteEndElement();

                descWriter.WriteStartElement("actionList");

                MethodInfo[] methods = GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic);
                foreach (MethodInfo method in methods)
                {
                    //IEnumerable<UpnpServiceArgument> methAttribs = method.GetCustomAttributes(typeof(UpnpServiceArgument), true).Cast<UpnpServiceArgument>();
                    //ParameterInfo[] parameters = method.GetParameters();

                    //if (methAttribs.Count() > 0 || parameters.Any(a => a.GetCustomAttributes(typeof(UpnpServiceArgument), true).Length > 0))
                    //{
                    //    descWriter.WriteStartElement("action");
                    //    descWriter.WriteElementString("name", method.Name);
                    //    descWriter.WriteStartElement("argumentList");

                    //    //Zapisanie vstupnych parametrov
                    //    foreach (ParameterInfo parameter in parameters)
                    //    {
                    //        //UpnpServiceArgument paramAttrib = parameter.GetCustomAttributes(typeof(UpnpServiceArgument), true).FirstOrDefault() as UpnpServiceArgument;
                    //        //if (paramAttrib != null)
                    //        //{
                    //        //    descWriter.WriteStartElement("argument");
                    //        //    descWriter.WriteElementString("name", parameter.Name);
                    //        //    descWriter.WriteElementString("direction", "in");
                    //        //    descWriter.WriteElementString("relatedStateVariable", paramAttrib.RelatedStateVariable);
                    //        //    descWriter.WriteEndElement();
                    //        //}
                    //    }

                    //    //Zapisanie vystupnych parametrov
                    //    //foreach (UpnpServiceArgument methAttrib in methAttribs.OrderBy(a => a.Index))
                    //    //{
                    //    //    descWriter.WriteStartElement("argument");
                    //    //    descWriter.WriteElementString("name", methAttrib.Name);
                    //    //    descWriter.WriteElementString("direction", "out");
                    //    //    descWriter.WriteElementString("relatedStateVariable", methAttrib.RelatedStateVariable);
                    //    //    descWriter.WriteEndElement();
                    //    //}

                    //    descWriter.WriteEndElement();
                    //    descWriter.WriteEndElement();
                    //}
                }

                descWriter.WriteEndElement();
                descWriter.WriteStartElement("serviceStateTable");

                //Zapisanie premennych
                //foreach (UpnpServiceVariable variable in GetType().GetCustomAttributes(typeof(UpnpServiceVariable), true).Cast<UpnpServiceVariable>())
                //{
                //    descWriter.WriteStartElement("stateVariable");
                //    descWriter.WriteAttributeString("sendEvents", variable.SendEvents ? "yes" : "no");
                //    descWriter.WriteElementString("name", variable.Name);
                //    descWriter.WriteElementString("dataType", variable.DataType);
                //    if (variable.AllowedValue.Length > 0)
                //    {
                //        descWriter.WriteStartElement("allowedValueList");
                //        foreach (string value in variable.AllowedValue)
                //            descWriter.WriteElementString("allowedValue", value);
                //        descWriter.WriteEndElement();
                //    }
                //    descWriter.WriteEndElement();
                //}

                descWriter.WriteEndElement();

                descWriter.WriteEndElement();

                descWriter.Flush();
                this.descArray = memStream.ToArray();
            }

            //server.HttpServer.AddRoute("GET", SCPDURL, new HttpRouteDelegate(GetDescription));
            //server.HttpServer.AddRoute("POST", controlUrl, new HttpRouteDelegate(ProceedControl));
            //server.HttpServer.AddRoute("SUBSCRIBE", eventSubUrl, new HttpRouteDelegate(ProceedEventSub));
            //server.HttpServer.AddRoute("UNSUBSCRIBE", eventSubUrl, new HttpRouteDelegate(ProceedEventUnsub));
        }