DeviceAvailableEventArgs.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Net;
  3. namespace Rssdp
  4. {
  5. /// <summary>
  6. /// Event arguments for the <see cref="Infrastructure.SsdpDeviceLocatorBase.DeviceAvailable"/> event.
  7. /// </summary>
  8. public sealed class DeviceAvailableEventArgs : EventArgs
  9. {
  10. public IPAddress RemoteIpAddress { get; set; }
  11. private readonly DiscoveredSsdpDevice _DiscoveredDevice;
  12. private readonly bool _IsNewlyDiscovered;
  13. /// <summary>
  14. /// Full constructor.
  15. /// </summary>
  16. /// <param name="discoveredDevice">A <see cref="DiscoveredSsdpDevice"/> instance representing the available device.</param>
  17. /// <param name="isNewlyDiscovered">A boolean value indicating whether or not this device came from the cache. See <see cref="IsNewlyDiscovered"/> for more detail.</param>
  18. /// <exception cref="ArgumentNullException">Thrown if the <paramref name="discoveredDevice"/> parameter is null.</exception>
  19. public DeviceAvailableEventArgs(DiscoveredSsdpDevice discoveredDevice, bool isNewlyDiscovered)
  20. {
  21. if (discoveredDevice == null)
  22. {
  23. throw new ArgumentNullException(nameof(discoveredDevice));
  24. }
  25. _DiscoveredDevice = discoveredDevice;
  26. _IsNewlyDiscovered = isNewlyDiscovered;
  27. }
  28. /// <summary>
  29. /// Returns true if the device was discovered due to an alive notification, or a search and was not already in the cache. Returns false if the item came from the cache but matched the current search request.
  30. /// </summary>
  31. public bool IsNewlyDiscovered
  32. {
  33. get { return _IsNewlyDiscovered; }
  34. }
  35. /// <summary>
  36. /// A reference to a <see cref="DiscoveredSsdpDevice"/> instance containing the discovered details and allowing access to the full device description.
  37. /// </summary>
  38. public DiscoveredSsdpDevice DiscoveredDevice
  39. {
  40. get { return _DiscoveredDevice; }
  41. }
  42. }
  43. }