コード例 #1
0
 /// <summary>
 /// Removes the announcer.
 /// </summary>
 /// <param name="announcer">The announcer.</param>
 public void RemoveAnnouncer(SsdpAnnouncer announcer)
 {
     lock (this.Announcers)
     {
         this.Announcers.Remove(announcer);
     }
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
ファイル: SsdpServer.cs プロジェクト: johnduhart/Upnp
 /// <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;
     }
 }
コード例 #4
0
 /// <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);
     }
 }
コード例 #5
0
ファイル: SsdpServer.cs プロジェクト: automaters/Upnp
 /// <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;
     }
 }
コード例 #6
0
        /// <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;
            }
        }
コード例 #7
0
        /// <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);
            }
        }
コード例 #8
0
ファイル: UpnpServer.cs プロジェクト: automaters/Upnp
        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;
        }
コード例 #9
0
ファイル: SsdpServer.cs プロジェクト: automaters/Upnp
 /// <summary>
 /// Removes the announcer.
 /// </summary>
 /// <param name="announcer">The announcer.</param>
 public void RemoveAnnouncer(SsdpAnnouncer announcer)
 {
     lock (this.Announcers)
     {
         this.Announcers.Remove(announcer);
     }
 }
コード例 #10
0
ファイル: SsdpServer.cs プロジェクト: automaters/Upnp
        /// <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);
            }
        }
コード例 #11
0
ファイル: SsdpServer.cs プロジェクト: automaters/Upnp
        /// <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;
            }
        }