/// <summary> /// Contains information about the location of a device on the network. /// </summary> /// <param name="Client">UPnP Client</param> /// <param name="Headers">All headers in notification.</param> /// <param name="LocalEndPoint">Local End Point.</param> /// <param name="RemoteEndPoint">Remote End Point.</param> internal NotificationEventArgs(UPnPClient Client, UPnPHeaders Headers, IPEndPoint LocalEndPoint, IPEndPoint RemoteEndPoint) { this.client = Client; this.headers = Headers; this.localEndPoint = LocalEndPoint; this.remoteEndPoint = RemoteEndPoint; }
/// <summary> /// Contains information about the location of a device on the network. /// </summary> /// <param name="SearchTarget">SSDP Search Target</param> /// <param name="Server">Server</param> /// <param name="Location">Location of device information</param> /// <param name="UniqueServiceName">Unique Service Name (USN)</param> /// <param name="Headers">All headers in response.</param> internal DeviceLocation(UPnPClient Client, string SearchTarget, string Server, string Location, string UniqueServiceName, UPnPHeaders Headers) { this.client = Client; this.searchTarget = SearchTarget; this.server = Server; this.location = Location; this.uniqueServiceName = UniqueServiceName; this.headers = Headers; }
private void EndReceiveOutgoing(IAsyncResult ar) { try { UdpClient UdpClient = (UdpClient)ar.AsyncState; IPEndPoint RemoteIP = null; byte[] Packet = UdpClient.EndReceive(ar, ref RemoteIP); string Header = Encoding.ASCII.GetString(Packet); UPnPHeaders Headers = new UPnPHeaders(Header); if (!(RemoteIP is null) && Headers.Direction == HttpDirection.Response && Headers.HttpVersion >= 1.0 && Headers.ResponseCode == 200) { if (!string.IsNullOrEmpty(Headers.Location)) { UPnPDeviceLocationEventHandler h = this.OnDeviceFound; if (!(h is null)) { DeviceLocation DeviceLocation = new DeviceLocation(this, Headers.SearchTarget, Headers.Server, Headers.Location, Headers.UniqueServiceName, Headers); DeviceLocationEventArgs e = new DeviceLocationEventArgs(DeviceLocation, (IPEndPoint)UdpClient.Client.LocalEndPoint, RemoteIP); try { h(this, e); } catch (Exception ex) { this.RaiseOnError(ex); } } } } else if (Headers.Direction == HttpDirection.Request && Headers.HttpVersion >= 1.0) { this.HandleIncoming(UdpClient, RemoteIP, Headers); } UdpClient.BeginReceive(this.EndReceiveOutgoing, UdpClient); }