/// <summary> /// Removes the announcer. /// </summary> /// <param name="announcer">The announcer.</param> public void RemoveAnnouncer(SsdpAnnouncer announcer) { lock (this.Announcers) { this.Announcers.Remove(announcer); } }
/// <summary> /// Creates the announcer. /// </summary> /// <param name="respondToSearches">if set to <c>true</c> [respond to searches].</param> /// <returns></returns> public ISsdpAnnouncer CreateAnnouncer(bool respondToSearches = true) { lock (this.Announcers) { var announcer = new SsdpAnnouncer(this.Sockets.ToArray()); this.Announcers.Add(announcer, respondToSearches); return(announcer); } }
/// <summary> /// Creates the announcer. /// </summary> /// <param name="respondToSearches">if set to <c>true</c> [respond to searches].</param> /// <returns></returns> public ISsdpAnnouncer CreateAnnouncer(bool respondToSearches = true) { lock (this.Announcers) { var announcer = new SsdpAnnouncer(this.Sockets.ToArray()); this.Announcers.Add(announcer, respondToSearches); return announcer; } }
/// <summary> /// Creates the announcer. /// </summary> /// <param name="respondToSearches">if set to <c>true</c> [respond to searches].</param> /// <returns></returns> public SsdpAnnouncer CreateAnnouncer(bool respondToSearches = true) { lock (this.Announcers) { var announcer = new SsdpAnnouncer(this.Server); this.Announcers.Add(announcer, respondToSearches); return(announcer); } }
/// <summary> /// Creates the announcer. /// </summary> /// <param name="respondToSearches">if set to <c>true</c> [respond to searches].</param> /// <returns></returns> public SsdpAnnouncer CreateAnnouncer(bool respondToSearches = true) { lock (this.Announcers) { var announcer = new SsdpAnnouncer(this.Server); this.Announcers.Add(announcer, respondToSearches); return announcer; } }
/// <summary> /// Sets the search responses. /// </summary> /// <param name="announcer">The announcer.</param> /// <param name="respondToSearches">if set to <c>true</c> [respond to searches].</param> public void SetSearchResponses(SsdpAnnouncer announcer, bool respondToSearches) { lock (this.Announcers) { if (!this.Announcers.ContainsKey(announcer)) { throw new KeyNotFoundException(); } this.Announcers[announcer] = respondToSearches; } }
/// <summary> /// Sends the search response message. /// </summary> protected void SendSearchResponse(SsdpMessage msg, SsdpAnnouncer announcer) { lock (this.Server) { // If we were stopped then don't bother sending this message if (!this.Server.IsListening) { return; } byte[] bytes = Encoding.ASCII.GetBytes(Protocol.CreateAliveResponse( announcer.Location, msg.SearchType, announcer.USN, announcer.MaxAge, Protocol.DefaultUserAgent));; this.Server.Send(bytes, bytes.Length, msg.Source); } }
private void SetupOnRemovedHandler(UpnpDevice device, SsdpAnnouncer ad1, SsdpAnnouncer ad2) { EventHandler<EventArgs<UpnpDevice>> onRemoved = null; onRemoved = (sender, args) => { ad1.Shutdown(); ad2.Shutdown(); this.Announcers.Remove(ad1); this.Announcers.Remove(ad2); device.Removed -= onRemoved; }; device.Removed += onRemoved; }
/// <summary> /// Sends the search response message. /// </summary> protected void SendSearchResponse(SsdpMessage msg, SsdpAnnouncer announcer) { lock (this.Server) { // If we were stopped then don't bother sending this message if (!this.Server.IsListening) return; byte[] bytes = Encoding.ASCII.GetBytes(Protocol.CreateAliveResponse( announcer.Location, msg.SearchType, announcer.USN, announcer.MaxAge, Protocol.DefaultUserAgent)); ; this.Server.Send(bytes, bytes.Length, msg.Source); } }
/// <summary> /// Sets the search responses. /// </summary> /// <param name="announcer">The announcer.</param> /// <param name="respondToSearches">if set to <c>true</c> [respond to searches].</param> public void SetSearchResponses(SsdpAnnouncer announcer, bool respondToSearches) { lock (this.Announcers) { if (!this.Announcers.ContainsKey(announcer)) throw new KeyNotFoundException(); this.Announcers[announcer] = respondToSearches; } }