/// <summary> /// Full constructor. /// </summary> /// <param name="communicationsServer">The <see cref="ISsdpCommunicationsServer"/> implementation, used to send and receive SSDP network messages.</param> /// <param name="osName">Then name of the operating system running the server.</param> /// <param name="osVersion">The version of the operating system running the server.</param> /// <param name="log">An implementation of <see cref="ISsdpLogger"/> to be used for logging activity. May be null, in which case no logging is performed.</param> protected SsdpDevicePublisherBase(ISsdpCommunicationsServer communicationsServer, string osName, string osVersion, ISsdpLogger log) { if (communicationsServer == null) { throw new ArgumentNullException("communicationsServer"); } if (osName == null) { throw new ArgumentNullException("osName"); } if (osName.Length == 0) { throw new ArgumentException("osName cannot be an empty string.", "osName"); } if (osVersion == null) { throw new ArgumentNullException("osVersion"); } if (osVersion.Length == 0) { throw new ArgumentException("osVersion cannot be an empty string.", "osName"); } _Log = log ?? NullLogger.Instance; _SupportPnpRootDevice = true; _Devices = new List <SsdpRootDevice>(); _ReadOnlyDevices = new ReadOnlyEnumerable <SsdpRootDevice>(_Devices); _RecentSearchRequests = new Dictionary <string, SearchRequest>(StringComparer.OrdinalIgnoreCase); _Random = new Random(); _DeviceValidator = new Upnp10DeviceValidator(); //Should probably inject this later, but for now we only support 1.0. _CommsServer = communicationsServer; _CommsServer.RequestReceived += CommsServer_RequestReceived; _OSName = osName; _OSVersion = osVersion; _Log.LogInfo("Publisher started."); _CommsServer.BeginListeningForBroadcasts(); _Log.LogInfo("Publisher started listening for broadcasts."); }
/// <summary> /// Full constructor. /// </summary> /// <remarks> /// <para>Allows the caller to specify their own <see cref="ISsdpCommunicationsServer"/> implementation for full control over the networking, or for mocking/testing purposes..</para> /// </remarks> public SsdpDevicePublisher(ISsdpCommunicationsServer communicationsServer, ISsdpLogger log) : base(communicationsServer, GetOSName(), GetOSVersion(), log ?? new SsdpTraceLogger()) { }
public Discovery(ISsdpCommunicationsServer communicationsServer, string osName, string osVersion, ISsdpLogger log) : base(communicationsServer, osName, osVersion, log) { }