Class AggregateSsdpDeviceLocator
Aggregates multiple SsdpDeviceLocator instances bound to different local adapter IP addresses to enable discovery across multiple network interfaces.
Inheritance
Inherited Members
Namespace: Rssdp
Assembly: cs.temp.dll.dll
Syntax
public sealed class AggregateSsdpDeviceLocator : IDisposable, ISsdpDeviceLocator
Constructors
AggregateSsdpDeviceLocator(Boolean, Boolean, Func<NetworkInterface, Boolean>, ISsdpLogger)
Creates an aggregate device locator by discovering local adapter IP addresses.
Declaration
public AggregateSsdpDeviceLocator(bool includeIpv4 = true, bool includeIpv6 = false, Func<NetworkInterface, bool> adapterFilter = null, ISsdpLogger logger = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | includeIpv4 | If true, include IPv4 addresses. |
| System.Boolean | includeIpv6 | If true, include IPv6 addresses. |
| System.Func<System.Net.NetworkInformation.NetworkInterface, System.Boolean> | adapterFilter | Optional filter to include only specific adapters. If null, a sensible default filter is applied. |
| ISsdpLogger | logger | Optional logger for diagnostics. |
AggregateSsdpDeviceLocator(IEnumerable<String>, ISsdpLogger)
Creates an aggregate device locator that queries multiple network adapters.
Declaration
public AggregateSsdpDeviceLocator(IEnumerable<string> localIpAddresses, ISsdpLogger logger = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | localIpAddresses | A collection of local adapter IP addresses to bind individual locators to. Null/empty entries are ignored. Must contain at least one valid address. |
| ISsdpLogger | logger | Optional logger for diagnostics. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
| System.ArgumentException | Thrown when no valid IP addresses are provided. |
Properties
IsSearching
Indicates whether a search is currently in progress across any aggregated locator.
Declaration
public bool IsSearching { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
NotificationFilter
Gets or sets the filter for notifications. Notifications not matching the filter will not raise DeviceAvailable or DeviceUnavailable. The value is applied to all aggregated locators.
Declaration
public string NotificationFilter { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
Dispose()
Disposes the aggregate locator and all underlying locators, detaching event handlers.
Declaration
public void Dispose()
SearchAsync(String, CancellationToken)
Asynchronously performs a search for the specified search target using the default timeout across all aggregated locators.
Declaration
public Task<IEnumerable<DiscoveredSsdpDevice>> SearchAsync(string searchTarget, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | searchTarget | Search criteria such as device type, root device, or UUID. |
| System.Threading.CancellationToken | cancellationToken | A token used to cancel the search across all locators. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<DiscoveredSsdpDevice>> | A task whose result is a de-duplicated sequence of discovered devices. |
SearchAsync(String, TimeSpan, CancellationToken)
Asynchronously performs a search for the specified search target using the provided timeout across all aggregated locators.
Declaration
public Task<IEnumerable<DiscoveredSsdpDevice>> SearchAsync(string searchTarget, TimeSpan searchWaitTime, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | searchTarget | Search criteria such as device type, root device, or UUID. |
| System.TimeSpan | searchWaitTime | The time to wait for responses. |
| System.Threading.CancellationToken | cancellationToken | A token used to cancel the search across all locators. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<DiscoveredSsdpDevice>> | A task whose result is a de-duplicated sequence of discovered devices. |
SearchAsync(CancellationToken)
Asynchronously performs a search for all devices using the default search timeout across all aggregated locators.
Declaration
public Task<IEnumerable<DiscoveredSsdpDevice>> SearchAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | cancellationToken | A token used to cancel the search across all locators. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<DiscoveredSsdpDevice>> | A task whose result is a de-duplicated sequence of discovered devices. |
SearchAsync(TimeSpan, CancellationToken)
Asynchronously performs a search for all devices using the provided timeout across all aggregated locators.
Declaration
public Task<IEnumerable<DiscoveredSsdpDevice>> SearchAsync(TimeSpan searchWaitTime, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.TimeSpan | searchWaitTime | The time to wait for responses. |
| System.Threading.CancellationToken | cancellationToken | A token used to cancel the search across all locators. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<DiscoveredSsdpDevice>> | A task whose result is a de-duplicated sequence of discovered devices. |
StartListeningForNotifications()
Starts listening for broadcast notifications of device availability on all aggregated locators.
Declaration
public void StartListeningForNotifications()
StartListeningForNotificationsAsync()
Asynchronously starts listening for multicast notifications on all aggregated locators and awaits per-adapter completion.
Declaration
public async Task StartListeningForNotificationsAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
StopListeningForNotifications()
Stops listening for broadcast notifications on all aggregated locators.
Declaration
public void StopListeningForNotifications()
StopListeningForNotificationsAsync()
Asynchronously stops listening for multicast notifications on all aggregated locators and awaits per-adapter completion.
Declaration
public async Task StopListeningForNotificationsAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
Events
DeviceAvailable
Raised when a device becomes available or is found by a search request across any aggregated locator.
Declaration
public event EventHandler<DeviceAvailableEventArgs> DeviceAvailable
Event Type
| Type | Description |
|---|---|
| System.EventHandler<DeviceAvailableEventArgs> |
DeviceUnavailable
Raised when a device explicitly notifies of shutdown or expires from the cache across any aggregated locator.
Declaration
public event EventHandler<DeviceUnavailableEventArgs> DeviceUnavailable
Event Type
| Type | Description |
|---|---|
| System.EventHandler<DeviceUnavailableEventArgs> |