public bool Equal(UpnpNt other) { if (this.Type != other.Type) { return(false); } switch (this.Type) { case NtType.RootDevice: return(true); case NtType.Guid: return((other.id == this.id) ? true : false); case NtType.DeviceType: case NtType.ServiceType: return((other.ItemVersion == this.ItemVersion && other.ItemType == this.ItemType) ? true : false); case NtType.DomainDeviceType: case NtType.DomainServiceType: return((other.ItemVersion == this.ItemVersion && other.ItemType == this.ItemType && this.DomainName == other.DomainName) ? true : false); case NtType.DomainCustomType: return((other.ItemVersion == this.ItemVersion && other.ItemType == this.ItemType && this.DomainName == other.DomainName && other.ItemCuston == this.ItemCuston) ? true : false); case NtType.CustomType: return((other.ItemVersion == this.ItemVersion && other.ItemType == this.ItemType && other.ItemCuston == this.ItemCuston) ? true : false); default: return(false); } }
public static UpnpUsn Parse(string usn) { UpnpNt nt = null; int SplitIndex = usn.IndexOf("::"); if (SplitIndex != -1) { nt = UpnpNt.Parse(usn.Substring(SplitIndex + 1)); usn = usn.Substring(0, SplitIndex); } string[] usnParts = usn.Trim().Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries); if (usnParts.Length != 2) { throw new Exception("Unable to parse upnp usn, invaild amount"); } if (usnParts[0] == "uuid") { throw new Exception("Unable to parse upnp usn, invaild starting"); } if (Guid.TryParse(usnParts[1], out Guid usnId)) { return(new UpnpUsn(usnId, nt)); } else { throw new Exception("Unable to parse upnp usn, invaild guid"); } }
public UpnpSsdpQueryResponse(int maxAge, UpnpNt searchObject, UpnpUsn targetDevice, string location) : base("HTTP/1.1", 200, "OK", new HttpHeaders( new HttpHeader[] { new HttpHeader("CACHE-CONTROL", $"max-age={maxAge}"), new HttpHeader("DATE", DateTime.Now.ToString("o")), new HttpHeader("ST", searchObject.ToString()), new HttpHeader("USN", targetDevice.ToString()), new HttpHeader("EXT", ""), new HttpHeader("SERVER", "PowerLine/1 UPnP/1.0 PowerLineUpnp/1"), new HttpHeader("LOCATION", location), })) { }
public UpnpUsn(Guid id, UpnpNt nt) { this.id = id; Nt = nt; }