Exemple #1
0
 public void AddExtraHeader(string header, object value)
 {
     if (value != null && !RawHeaders.ContainsKey(header))
     {
         RawHeaders.Add(header, value);
     }
 }
Exemple #2
0
        }             // RemoveSearchResult()

        /// <summary>
        /// Sends the search response.
        /// </summary>
        /// <param name="remoteEndpoint">The remote endpoint.</param>
        /// <param name="sendClient">The send client.</param>
        private static void SendSearchRequest(IPEndPoint remoteEndpoint, UdpClient sendClient)
        {
            var headers = new RawHeaders();

            headers.Add("HOST", "239.255.255.250:1900");
            ////headers.Add("ST", QueryAll);
            headers.Add("ST", QueryDevices);
            headers.Add("MAN", "\"ssdp:discover\"");
            headers.Add("MX", SecondsForSearch.ToString());

            var dgram = new Datagram(remoteEndpoint, sendClient,
                                     $"M-SEARCH * HTTP/1.1\r\n{headers.HeaderBlock}\r\n",
                                     false);

            dgram.Send();
        } // SendSearchRequest()
Exemple #3
0
        internal void NotifyDevice(UpnpDevice dev, string type, bool sticky)
        {
            Debug("NotifyDevice");
            var headers = new RawHeaders();

            headers.Add("HOST", "239.255.255.250:1900");
            headers.Add("CACHE-CONTROL", "max-age = 600");
            headers.Add("LOCATION", dev.Descriptor.ToString());
            headers.Add("SERVER", HttpServer.Signature);
            headers.Add("NTS", "ssdp:" + type);
            headers.Add("NT", dev.Type);
            headers.Add("USN", dev.USN);

            SendDatagram(
                SSDP_ENDP,
                dev.Address,
                String.Format("NOTIFY * HTTP/1.1\r\n{0}\r\n", headers.HeaderBlock),
                sticky
                );
            // Some buggy network equipment will swallow multicast packets, so lets
            // cheat, increase the odds, by sending to broadcast.
            SendDatagram(
                BROAD_ENDP,
                dev.Address,
                String.Format("NOTIFY * HTTP/1.1\r\n{0}\r\n", headers.HeaderBlock),
                sticky
                );
            DebugFormat("{0} said {1}", dev.USN, type);
        }
Exemple #4
0
        /// <summary>
        ///     Adds a single header or updates it if it already exists
        /// </summary>
        /// <param name="headerName">The name of the header</param>
        /// <param name="headerValue">The value for the header</param>
        public void SetHeaderValue(string headerName, string headerValue)
        {
            if (!RawHeaders.ContainsKey(headerName))
            {
                RawHeaders.Add(headerName, new List <string> {
                    headerValue
                });
            }
            else
            {
                RawHeaders[headerName] = new List <string> {
                    headerValue
                }
            };

            ParseHeader(headerName, headerValue);
        }
Exemple #5
0
        private void SendSearchResponse(IPEndPoint endpoint, UpnpDevice dev)
        {
            var headers = new RawHeaders();

            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", HttpServer.Signature);
            headers.Add("ST", dev.Type);
            headers.Add("USN", dev.USN);

            SendDatagram(endpoint, dev.Address, String.Format("HTTP/1.1 200 OK\r\n{0}\r\n", headers.HeaderBlock), false);
            InfoFormat("{2}, {1} - Responded to a {0} request", dev.Type, endpoint, dev.Address);
        }
Exemple #6
0
        internal void NotifyDevice(UpnpDevice dev, string type, bool sticky)
        {
            Debug("NotifyDevice");
            var headers = new RawHeaders();

            headers.Add("HOST", "239.255.255.250:1900");
            headers.Add("CACHE-CONTROL", "max-age = 600");
            headers.Add("LOCATION", dev.Descriptor.ToString());
            headers.Add("SERVER", HttpServer.Signature);
            headers.Add("NTS", "ssdp:" + type);
            headers.Add("NT", dev.Type);
            headers.Add("USN", dev.USN);

            SendDatagram(SSDP_ENDP, dev.Address, String.Format("NOTIFY * HTTP/1.1\r\n{0}\r\n", headers.HeaderBlock), sticky);
            DebugFormat("{0} said {1}", dev.USN, type);
        }
Exemple #7
0
    internal void NotifyDevice(UpnpDevice dev, string type, bool sticky)
    {
      Debug("NotifyDevice");
      var headers = new RawHeaders();
      headers.Add("HOST", "239.255.255.250:1900");
      headers.Add("CACHE-CONTROL", "max-age = 600");
      headers.Add("LOCATION", dev.Descriptor.ToString());
      headers.Add("SERVER", HttpServer.Signature);
      headers.Add("NTS", "ssdp:" + type);
      headers.Add("NT", dev.Type);
      headers.Add("USN", dev.USN);

      SendDatagram(
        SSDP_ENDP,
        dev.Address,
        String.Format("NOTIFY * HTTP/1.1\r\n{0}\r\n", headers.HeaderBlock),
        sticky
        );
      DebugFormat("{0} said {1}", dev.USN, type);
    }
Exemple #8
0
    private void SendSearchResponse(IPEndPoint endpoint, UpnpDevice dev)
    {
      var headers = new RawHeaders();
      headers.Add("CACHE-CONTROL", "max-age = 600");
      headers.Add("DATE", DateTime.Now.ToString("R"));
      headers.Add("EXT", string.Empty);
      headers.Add("LOCATION", dev.Descriptor.ToString());
      headers.Add("SERVER", HttpServer.Signature);
      headers.Add("ST", dev.Type);
      headers.Add("USN", dev.USN);

      SendDatagram(
        endpoint,
        dev.Address,
        String.Format("HTTP/1.1 200 OK\r\n{0}\r\n", headers.HeaderBlock),
        false
        );
      InfoFormat(
        "{2}, {1} - Responded to a {0} request", dev.Type, endpoint,
        dev.Address);
    }
Exemple #9
0
        internal void NotifyDevice(UpnpDevice dev, string type, bool sticky)
        {
            _logger.Debug("NotifyDevice");
              var headers = new RawHeaders();
              headers.Add("HOST", "239.255.255.250:1900");
              headers.Add("CACHE-CONTROL", "max-age = 600");
              headers.Add("LOCATION", dev.Descriptor.ToString());
              headers.Add("SERVER", HttpServer.Signature);
              headers.Add("NTS", "ssdp:" + type);
              headers.Add("NT", dev.Type);
              headers.Add("USN", dev.USN);

              SendDatagram(
            SSDP_ENDP,
            dev.Address,
            String.Format("NOTIFY * HTTP/1.1\r\n{0}\r\n", headers.HeaderBlock),
            sticky
            );
              // Some buggy network equipment will swallow multicast packets, so lets
              // cheat, increase the odds, by sending to broadcast.
              SendDatagram(
            BROAD_ENDP,
            dev.Address,
            String.Format("NOTIFY * HTTP/1.1\r\n{0}\r\n", headers.HeaderBlock),
            sticky
            );
              _logger.DebugFormat("{0} said {1}", dev.USN, type);
        }