Esempio n. 1
0
        /// <summary>
        /// Causes the server to stop listening for multicast messages, being SSDP search requests and notifications.
        /// </summary>
        /// <exception cref="System.ObjectDisposedException">Thrown if the <see cref="DisposableManagedObjectBase.IsDisposed"/> property is true (because <seealso cref="DisposableManagedObjectBase.Dispose()" /> has been called previously).</exception>
        public void StopListeningForBroadcasts()
        {
            ThrowIfDisposed();

            lock (_BroadcastListenSocketSynchroniser)
            {
                if (_BroadcastListenSocket != null)
                {
                    _BroadcastListenSocket.Dispose();
                    _BroadcastListenSocket = null;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Stops this instance.
        /// </summary>
        public void Stop()
        {
            _isDisposed = true;

            if (_udpClient != null)
            {
                _udpClient.Dispose();
            }
        }
 private void Dispose(bool disposing)
 {
     if (!_isDisposed)
     {
         if (disposing)
         {
             _connectCancelToken?.Dispose();
             _udp?.Dispose();
             WebSocketClient?.Dispose();
             _connectionLock?.Dispose();
         }
         _isDisposed = true;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Stops listening for search responses on the local, unicast socket.
        /// </summary>
        /// <exception cref="System.ObjectDisposedException">Thrown if the <see cref="DisposableManagedObjectBase.IsDisposed"/> property is true (because <seealso cref="DisposableManagedObjectBase.Dispose()" /> has been called previously).</exception>
        public void StopListeningForResponses()
        {
            ThrowIfDisposed();

            lock ( _SendSocketSynchroniser ) {
                IUdpSocket socket = _SendSocket;
                _SendSocket = null;

                if (socket != null)
                {
                    socket.Dispose();
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Stops listening for requests, disposes this instance and all internal resources.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                lock (_BroadcastListenSocketSynchroniser)
                {
                    if (_BroadcastListenSocket != null)
                    {
                        _BroadcastListenSocket.Dispose();
                    }
                }

                lock (_SendSocketSynchroniser)
                {
                    if (_SendSocket != null)
                    {
                        _SendSocket.Dispose();
                    }
                }
            }
        }