• API Documentation
Show / Hide Table of Contents
  • Rssdp
    • AggregateSsdpDeviceLocator
    • CustomHttpHeader
    • CustomHttpHeadersCollection
    • DeviceAvailableEventArgs
    • DeviceEventArgs
    • DeviceNetworkType
    • DeviceNetworkTypeExtensions
    • DeviceUnavailableEventArgs
    • DiscoveredSsdpDevice
    • ExceptionExtensions
    • ISsdpLogger
    • NullLogger
    • ServiceEventArgs
    • SocketClosedException
    • SocketFactory
    • SsdpDevice
    • SsdpDeviceExtensions
    • SsdpDeviceIcon
    • SsdpDeviceLocator
    • SsdpDevicePropertiesCollection
    • SsdpDeviceProperty
    • SsdpDevicePublisher
    • SsdpEmbeddedDevice
    • SsdpRootDevice
    • SsdpService
    • SsdpStandardsMode
    • SsdpTraceLogger
  • Rssdp.Infrastructure
    • DisposableManagedObjectBase
    • HttpParserBase<T>
    • HttpRequestParser
    • HttpResponseParser
    • ISocketFactory
    • ISsdpCommunicationsServer
    • ISsdpDeviceLocator
    • ISsdpDevicePublisher
    • IUdpSocket
    • IUpnpDeviceValidator
    • ReceivedUdpData
    • RequestReceivedEventArgs
    • ResponseReceivedEventArgs
    • SsdpCommunicationsServer
    • SsdpConstants
    • SsdpDeviceLocatorBase
    • SsdpDevicePublisherBase
    • UdpEndPoint
    • Upnp10DeviceValidator

Class SsdpDevicePublisherBase

Provides the platform independent logic for publishing SSDP devices (notifications and search responses).

Inheritance
System.Object
DisposableManagedObjectBase
SsdpDevicePublisherBase
SsdpDevicePublisher
Implements
System.IDisposable
ISsdpDevicePublisher
Inherited Members
DisposableManagedObjectBase.ThrowIfDisposed()
DisposableManagedObjectBase.IsDisposed
DisposableManagedObjectBase.Dispose()
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Rssdp.Infrastructure
Assembly: cs.temp.dll.dll
Syntax
public abstract class SsdpDevicePublisherBase : DisposableManagedObjectBase, IDisposable, ISsdpDevicePublisher

Constructors

SsdpDevicePublisherBase(ISsdpCommunicationsServer, String, String)

Default constructor.

Declaration
protected SsdpDevicePublisherBase(ISsdpCommunicationsServer communicationsServer, string osName, string osVersion)
Parameters
Type Name Description
ISsdpCommunicationsServer communicationsServer

The ISsdpCommunicationsServer implementation, used to send and receive SSDP network messages.

System.String osName

Then name of the operating system running the server.

System.String osVersion

The version of the operating system running the server.

SsdpDevicePublisherBase(ISsdpCommunicationsServer, String, String, ISsdpLogger)

Partial constructor.

Declaration
protected SsdpDevicePublisherBase(ISsdpCommunicationsServer communicationsServer, string osName, string osVersion, ISsdpLogger log)
Parameters
Type Name Description
ISsdpCommunicationsServer communicationsServer

The ISsdpCommunicationsServer implementation, used to send and receive SSDP network messages.

System.String osName

Then name of the operating system running the server.

System.String osVersion

The version of the operating system running the server.

ISsdpLogger log

An implementation of ISsdpLogger to be used for logging activity. May be null, in which case no logging is performed.

SsdpDevicePublisherBase(ISsdpCommunicationsServer, String, String, ISsdpLogger, IUpnpDeviceValidator)

Full constructor.

Declaration
protected SsdpDevicePublisherBase(ISsdpCommunicationsServer communicationsServer, string osName, string osVersion, ISsdpLogger log, IUpnpDeviceValidator deviceValidator)
Parameters
Type Name Description
ISsdpCommunicationsServer communicationsServer

The ISsdpCommunicationsServer implementation, used to send and receive SSDP network messages.

System.String osName

Then name of the operating system running the server.

System.String osVersion

The version of the operating system running the server.

ISsdpLogger log

An implementation of ISsdpLogger to be used for logging activity. May be null, in which case no logging is performed.

IUpnpDeviceValidator deviceValidator

An implementation of IUpnpDeviceValidator to be used to validate devices being added to the publisher.

Properties

ActivitySource

Provides the diagnostic ActivitySource used by this publisher for distributed tracing.

Declaration
protected ActivitySource ActivitySource { get; }
Property Value
Type Description
System.Diagnostics.ActivitySource

Devices

Returns a read only list of devices being published by this instance.

Declaration
public IEnumerable<SsdpRootDevice> Devices { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<SsdpRootDevice>

Log

Returns a reference to the injected ISsdpLogger instance.

Declaration
protected ISsdpLogger Log { get; }
Property Value
Type Description
ISsdpLogger
Remarks

Should never return null. If null was injected a reference to an internal null logger should be returned.

NotificationBroadcastInterval

Sets or returns a fixed interval at which alive notifications for services exposed by this publisher instance are broadcast.

Declaration
public TimeSpan NotificationBroadcastInterval { get; set; }
Property Value
Type Description
System.TimeSpan
Remarks

If this is set to System.TimeSpan.Zero then the system will follow the process recommended by the SSDP spec and calculate a randomised interval based on the cache life times of the published services. The default and recommended value is TimeSpan.Zero.

While (zero and) any positive System.TimeSpan value are allowed, the SSDP specification says notifications should not be broadcast more often than 15 minutes. If you wish to remain compatible with the SSDP specification, do not set this property to a value greater than zero but less than 15 minutes.

StandardsMode

Sets or returns a value from the SsdpStandardsMode controlling how strictly the publisher obeys the SSDP standard.

Declaration
public SsdpStandardsMode StandardsMode { get; set; }
Property Value
Type Description
SsdpStandardsMode
Remarks

Using relaxed mode will process search requests even if the MX header is missing.

SupportPnpRootDevice

If true (default) treats root devices as both upnp:rootdevice and pnp:rootdevice types.

Declaration
[Obsolete("Set StandardsMode to SsdpStandardsMode.Relaxed instead.")]
public bool SupportPnpRootDevice { get; set; }
Property Value
Type Description
System.Boolean
Remarks

Enabling this option will cause devices to show up in Microsoft Windows Explorer's network screens (if discovery is enabled etc.). Windows Explorer appears to search only for pnp:rootdeivce and not upnp:rootdevice.

If false, the system will only use upnp:rootdevice for notifiation broadcasts and and search responses, which is correct according to the UPnP/SSDP spec.

Methods

AddDevice(SsdpRootDevice)

Adds a device (and it's children) to the list of devices being published by this server, making them discoverable to SSDP clients.

Declaration
public void AddDevice(SsdpRootDevice device)
Parameters
Type Name Description
SsdpRootDevice device

The SsdpDevice instance to add.

Remarks

Adding a device causes "alive" notification messages to be sent immediately, or very soon after. Ensure your device/description service is running before adding the device object here.

Devices added here with a non-zero cache life time will also have notifications broadcast periodically.

This method ignores duplicate device adds (if the same device instance is added multiple times, the second and subsequent add calls do nothing).

Exceptions
Type Condition
System.ArgumentNullException

Thrown if the device argument is null.

System.InvalidOperationException

Thrown if the device contains property values that are not acceptable to the UPnP 1.0 specification.

Dispose(Boolean)

Stops listening for requests, stops sending periodic broadcasts, disposes all internal resources.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing
Overrides
DisposableManagedObjectBase.Dispose(Boolean)

RemoveDevice(SsdpRootDevice)

Removes a device (and it's children) from the list of devices being published by this server, making them undiscoverable.

Declaration
public void RemoveDevice(SsdpRootDevice device)
Parameters
Type Name Description
SsdpRootDevice device

The SsdpDevice instance to add.

Remarks

Removing a device causes "byebye" notification messages to be sent immediately, advising clients of the device/service becoming unavailable. We recommend removing the device from the published list before shutting down the actual device/service, if possible.

This method does nothing if the device was not found in the collection.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if the device argument is null.

Implements

System.IDisposable
ISsdpDevicePublisher
In This Article
Back to top Copyright (c) 2015 Troy Willmot