public UPnPConfigPackage(IIpConfig ip, IUPnPConfig upnp, IXMLWriter xw, List<string>servicepath)
 {
     IpConf = ip;
     UpnpConf = upnp;
     XmlWr = xw;
     ServiceConfPaths = servicepath;
 }
        public MulticastSender(IIpConfig ipconf, IUPnPConfig upnpconf)
        {
            _UUID = ipconf.GUID;
            _cacheexpire = upnpconf.cacheExpire;
            _localip = ipconf.IP;
            _tcpport = ipconf.TCPPort;
            _upnPConfig = upnpconf;

            SetupMulticastSender();     //Setup

            notify = HTTPNotifygenerator(upnpconf.NT);
        }
        //Todo: Separate into UDPHandler and UDPServer
        //Explicit contructor that takes the UPnPConfig classes:
        public UDPHandler(IIpConfig ipconf, IUPnPConfig upnpconf)
        {
            sender = new MulticastSender(ipconf, upnpconf);          //Creates sender
            receiver = new MulticastReceiver();
            //receiver = new MulticastReceiver(IpConf, upnpconf);     //Creates receiver

            NotifyThread = new Thread(sender.NotifySender);     //Thread for notifier. Runs every _cacheexpire seconds
            ReceiveThread = new Thread(Run);                    //Run thread. The default UDP Thread

            _ip = ipconf;
            _upnPConfig = upnpconf;
        }
        /// <summary>
        /// Constructor.
        /// Starts new thread containing the functionality.
        /// </summary>
        /// <param name="ipConf">IP configuration from factory</param>
        /// <param name="BasePath">Path to directory containing service and device descriptions</param>
        public TcpServer(IIpConfig ipConf, string BasePath)
        {
            localIp = ipConf.IP;
            localPort = ipConf.TCPPort;

            tcpHandle = new TCPHandle(BasePath, ipConf);

            //Todo: Any IPAddress and a port. Is this an EndPoint?
            //Todo: Should we listen at our own local IP only?
            welcomeSocket = new TcpListener(IPAddress.Any, localPort);
            serverThread = new Thread(ServerFunc);
            serverThread.Start();
        }
        public UPnP(IUPnPConfigPackage config)
        {
            IpConf = config.IpConf;
            UpnpConf = config.UpnpConf;
            XmlWriter = config.XmlWr;

            XmlWriter.GenDeviceDescription(UpnpConf);

            XMLServicesConfig ServiceConf = new XMLServicesConfig(config.ServiceConfPaths);

            TCPServer = new TcpServer(IpConf.IP, IpConf.TCPPort);
            UDPServer = new UDPHandler(IpConf, UpnpConf);
            UDPServer.Start();

            SubscribeToUpnpEvents();
        }
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="ip">IP of the upnp device that the device descriptions should be made for</param>
 /// <param name="upnp">UPnPConfig object that holds the needed data for the descriptions</param>
 public XMLWriter(IIpConfig ip, IUPnPConfig upnp)
 {
     _ip = ip;
     _upnp = upnp;
 }
 public XMLWriter(IIpConfig ip)
 {
     _ip = ip;
 }
        /*
        public string GenerateResponse(string ChangedProp, string value, ISubscriber sub)
        {
            UPnPArg arg = new UPnPArg();
            arg (new UPnPArg(ChangedProp, value));
            string body = EventResponse(arg);

            string head = EventHead (sub, ipconf, body.Length);

            return head + "\r\n" + body;
        }
        */
        /// <summary>
        /// Create the HTTP head for the event message.
        /// </summary>
        /// <param name="sub">Subscriber</param>
        /// <param name="ipconf">IP Configuration package</param>
        /// <param name="length">length of body</param>
        /// <returns></returns>
        public string EventHead(ISubscriber sub, IIpConfig ipconf, int length)
        {
            return  "NOTIFY /" + sub.DeliveryPath + " HTTP/1.1\r\n" +
                    "HOST: http://" + ipconf.IP + ":" + ipconf.TCPPort + "\r\n" +
                    "CONTENT-TYPE: text/xml\r\n" +
                    "CONTENT-LENGTH: " + length + "\r\n" +
                    "NT: upnp:event\r\n" +
                    "NTS: upnp:propchange\r\n" +
                    "SID: uuid:" + sub.UUID + "\r\n" +
                    "SEQ: " + sub.EventNo + "\r\n";
        }
 /// <summary>
 /// Constructor
 /// Configured with IIpConfig package.
 /// </summary>
 /// <param name="ip">IP Configure package</param>
 public Publisher(IIpConfig ip)
 {
     PropertyChangedEvent.PropEvent += PropertyChangedFunc;
     ipconf = ip;
     _Subscribtions = new List<Subscriber>();
 }
 //Why???
 //Todo: Remove, maybe???
 public TCPHandle(string BasePath, IIpConfig ipConf)
 {
     _basePath = BasePath;
     _pub = new Publisher(ipConf);
 }