Ejemplo n.º 1
0
        private void NotifyDevice(UpnpDevice dev, string type, bool sticky)
        {
            var builder = new StringBuilder();

            const string argFormat = "{0}: {1}\r\n";

            builder.Append("NOTIFY * HTTP/1.1\r\n{0}\r\n");
            builder.AppendFormat(argFormat, "HOST", "239.255.255.250:1900");
            builder.AppendFormat(argFormat, "CACHE-CONTROL", "max-age = 600");
            builder.AppendFormat(argFormat, "LOCATION", dev.Descriptor);
            builder.AppendFormat(argFormat, "SERVER", _serverSignature);
            builder.AppendFormat(argFormat, "NTS", "ssdp:" + type);
            builder.AppendFormat(argFormat, "NT", dev.Type);
            builder.AppendFormat(argFormat, "USN", dev.USN);
            builder.Append("\r\n");

            if (_config.Configuration.DlnaOptions.EnableDebugLogging)
            {
                _logger.Debug("{0} said {1}", dev.USN, type);
            }

            SendDatagram(_ssdpEndp, dev.Address, builder.ToString(), sticky);
        }
Ejemplo n.º 2
0
        private void NotifyDevice(UpnpDevice dev, string type, int sendCount, bool logMessage)
        {
            const string header = "NOTIFY * HTTP/1.1";

            var values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

            // If needed later for non-server devices, these headers will need to be dynamic 
            values["HOST"] = "239.255.255.250:1900";
            values["CACHE-CONTROL"] = "max-age = 600";
            values["LOCATION"] = dev.Descriptor.ToString();
            values["SERVER"] = _serverSignature;
            values["NTS"] = "ssdp:" + type;
            values["NT"] = dev.Type;
            values["USN"] = dev.USN;

            if (logMessage)
            {
                _logger.Debug("{0} said {1}", dev.USN, type);
            }

            SendDatagram(header, values, _ssdpEndp, new IPEndPoint(dev.Address, 0), true, sendCount);
        }
Ejemplo n.º 3
0
        private void NotifyDevice(UpnpDevice dev, string type, bool sticky)
        {
            var builder = new StringBuilder();

            const string argFormat = "{0}: {1}\r\n";

            builder.Append("NOTIFY * HTTP/1.1\r\n{0}\r\n");
            builder.AppendFormat(argFormat, "HOST", "239.255.255.250:1900");
            builder.AppendFormat(argFormat, "CACHE-CONTROL", "max-age = 600");
            builder.AppendFormat(argFormat, "LOCATION", dev.Descriptor);
            builder.AppendFormat(argFormat, "SERVER", _serverSignature);
            builder.AppendFormat(argFormat, "NTS", "ssdp:" + type);
            builder.AppendFormat(argFormat, "NT", dev.Type);
            builder.AppendFormat(argFormat, "USN", dev.USN);
            builder.Append("\r\n");

            if (_config.Configuration.DlnaOptions.EnableDebugLogging)
            {
                _logger.Debug("{0} said {1}", dev.USN, type);
            }

            SendDatagram(_ssdpEndp, dev.Address, builder.ToString(), sticky);
        }
Ejemplo n.º 4
0
        private void SendSearchResponse(IPEndPoint endpoint, UpnpDevice dev)
        {
            var builder = new StringBuilder();

            const string argFormat = "{0}: {1}\r\n";

            builder.Append("HTTP/1.1 200 OK\r\n");
            builder.AppendFormat(argFormat, "CACHE-CONTROL", "max-age = 600");
            builder.AppendFormat(argFormat, "DATE", DateTime.Now.ToString("R"));
            builder.AppendFormat(argFormat, "EXT", "");
            builder.AppendFormat(argFormat, "LOCATION", dev.Descriptor);
            builder.AppendFormat(argFormat, "SERVER", _serverSignature);
            builder.AppendFormat(argFormat, "ST", dev.Type);
            builder.AppendFormat(argFormat, "USN", dev.USN);
            builder.Append("\r\n");

            SendDatagram(endpoint, dev.Address, builder.ToString(), false);

            _logger.Info("{1} - Responded to a {0} request to {2}", dev.Type, endpoint, dev.Address.ToString());
        }
Ejemplo n.º 5
0
        private void NotifyDevice(UpnpDevice dev, string type, bool sticky)
        {
            _logger.Debug("NotifyDevice");
            var headers = new Headers(true);
            headers.Add("HOST", "239.255.255.250:1900");
            headers.Add("CACHE-CONTROL", "max-age = 600");
            headers.Add("LOCATION", dev.Descriptor.ToString());
            headers.Add("SERVER", _serverSignature);
            headers.Add("NTS", "ssdp:" + type);
            headers.Add("NT", dev.Type);
            headers.Add("USN", dev.USN);

            SendDatagram(_ssdpEndp, String.Format("NOTIFY * HTTP/1.1\r\n{0}\r\n", headers.HeaderBlock), sticky);
            _logger.Debug("{0} said {1}", dev.USN, type);
        }
Ejemplo n.º 6
0
        private void SendSearchResponse(IPEndPoint endpoint, UpnpDevice dev)
        {
            var headers = new Headers(true);
            headers.Add("CACHE-CONTROL", "max-age = 600");
            headers.Add("DATE", DateTime.Now.ToString("R"));
            headers.Add("EXT", "");
            headers.Add("LOCATION", dev.Descriptor.ToString());
            headers.Add("SERVER", _serverSignature);
            headers.Add("ST", dev.Type);
            headers.Add("USN", dev.USN);

            SendDatagram(endpoint, String.Format("HTTP/1.1 200 OK\r\n{0}\r\n", headers.HeaderBlock), false);
            _logger.Info("{1} - Responded to a {0} request", dev.Type, endpoint);
        }