/// <summary> /// Function to create event XML body. /// </summary> /// <param name="arg">Argument to convert to XML</param> /// <returns>string of XML body</returns> public string EventBody(UPnPArg arg) { XmlDocument doc = new XmlDocument (); XmlDeclaration dec = doc.CreateXmlDeclaration ("1.0", null, null); doc.AppendChild (dec); XmlElement prop = doc.CreateElement ("e", "propertyset", "schemas-upnp-org:event-1-0"); doc.AppendChild (prop); XmlElement property = doc.CreateElement ("property", "schemas-upnp-org:event-1-0"); property.Prefix = "e"; prop.AppendChild (property); XmlElement variable = doc.CreateElement (arg.ArgName); property.AppendChild (variable); variable.InnerText = arg.ArgVal; //Saved for debugging: //doc.Save(@"InvokeEvent.xml"); return doc.OuterXml; }
/// <summary> /// Handle GetIP requests and return the IP of the source adress. /// </summary> /// <param name="cb">CallBack delegate to respond to UPnP device</param> public void HandleGetIP(CallBack cb) { UPnPArg p = new UPnPArg("IPAddress", _sourceDevice.GetIP()); Console.WriteLine ("Arg: " + p.ArgVal); List<UPnPArg> argList = new List<UPnPArg>(); argList.Add (p); Console.WriteLine (">> UPnPARGLIST:"); Console.WriteLine (argList[0].ArgVal); cb(argList, "GetIPAddress"); }
/// <summary> /// Called whenever an evented variable changes state. /// Not implemented. /// </summary> /// <param name="e">Argument with value and type to be sent to control point</param> public void PropertyChangedFunc(UPnPArg e) { Console.WriteLine (" >> Prop Changed Event! <<"); string body = EventBody (e); /* if (_Subscribtions.Count > 0) { foreach (Subscriber sub in _Subscribtions) { string head = EventHead (sub, ipconf, body.Length); string msg = head + "\r\n" + body; Thread t = new Thread (new ParameterizedThreadStart (SendEventMsg)); object[] g = new object[] {sub, msg}; t.Start (g); } }*/ }