Пример #1
0
        public static void ParseURL(string ServiceURL, out string WebIP, out int Port, out string ServiceName)
        {
            Uri uri = new Uri(ServiceURL);

            WebIP = uri.Host;
            if (uri.HostNameType == UriHostNameType.Dns)
            {
                WebIP = Dns.GetHostByName(WebIP).AddressList[0].ToString();
            }
            Port        = uri.Port;
            ServiceName = HTTPMessage.UnEscapeString(uri.PathAndQuery);
        }
Пример #2
0
        private void GetHostByNameSink(IAsyncResult result)
        {
            IPHostEntry entry = null;

            try
            {
                entry = Dns.EndGetHostByName(result);
            }
            catch (Exception)
            {
                return;
            }
            object[] asyncState = (object[])result.AsyncState;
            Uri      uri        = (Uri)asyncState[0];
            object   tag        = asyncState[1];

            this.ContinueRequest(new IPEndPoint(entry.AddressList[0], uri.Port), HTTPMessage.UnEscapeString(uri.PathAndQuery), tag, null);
        }
Пример #3
0
 private void FetchServiceDocuments(UPnPDevice device)
 {
     for (int i = 0; i < device.Services.Length; i++)
     {
         HTTPMessage message  = new HTTPMessage();
         Uri         resource = new Uri(device.Services[i].SCPDURL);
         message.Directive    = "GET";
         message.DirectiveObj = HTTPMessage.UnEscapeString(resource.PathAndQuery);
         message.AddTag("Host", resource.Host + ":" + resource.Port.ToString());
         this.r.PipelineRequest(resource, device.Services[i]);
     }
     if (device.EmbeddedDevices.Length > 0)
     {
         for (int j = 0; j < device.EmbeddedDevices.Length; j++)
         {
             this.FetchServiceDocuments(device.EmbeddedDevices[j]);
         }
     }
 }
Пример #4
0
        public void PipelineRequest(Uri Resource, object Tag)
        {
            object[] stateObject = new object[] { Resource, Tag };
            string   host        = Resource.Host;

            if (Resource.HostNameType == UriHostNameType.Dns)
            {
                Dns.BeginGetHostByName(host, new AsyncCallback(this.GetHostByNameSink), stateObject);
            }
            else
            {
                this.ContinueRequest(new IPEndPoint(IPAddress.Parse(Resource.Host), Resource.Port), HTTPMessage.UnEscapeString(Resource.PathAndQuery), Tag, null);
            }
        }