Example #1
0
        public void Start()
        {
            lock (_internalLock)
            {
                try
                {
                    CheckDisposed();
                    if (_state == State.Started)
                    {
                        return;
                    }

                    HttpEndPointManager.AddListener(this);

                    _state = State.Started;
                }
                catch (Exception exception)
                {
                    _state = State.Closed;
                    if (NetEventSource.Log.IsEnabled())
                    {
                        NetEventSource.Error(this, $"Start {exception}");
                    }
                    throw;
                }
            }
        }
 public void Clear()
 {
     _listener.CheckDisposed();
     _prefixes.Clear();
     if (_listener.IsListening)
     {
         HttpEndPointManager.RemoveListener(_listener);
     }
 }
        public void Add(string uriPrefix)
        {
            _listener.CheckDisposed();
            ListenerPrefix.CheckUri(uriPrefix);
            if (_prefixes.Contains(uriPrefix))
            {
                return;
            }

            _prefixes.Add(uriPrefix);
            if (_listener.IsListening)
            {
                HttpEndPointManager.AddPrefix(uriPrefix, _listener);
            }
        }
        public bool Remove(string uriPrefix)
        {
            _listener.CheckDisposed();
            if (uriPrefix == null)
            {
                throw new ArgumentNullException(nameof(uriPrefix));
            }

            bool result = _prefixes.Remove(uriPrefix);

            if (result && _listener.IsListening)
            {
                HttpEndPointManager.RemovePrefix(uriPrefix, _listener);
            }

            return(result);
        }
Example #5
0
        private void CheckIfRemove()
        {
            if (_prefixes.Count > 0)
            {
                return;
            }

            List <ListenerPrefix> list = _unhandledPrefixes;

            if (list != null && list.Count > 0)
            {
                return;
            }

            list = _allPrefixes;
            if (list != null && list.Count > 0)
            {
                return;
            }

            HttpEndPointManager.RemoveEndPoint(this, _endpoint);
        }
Example #6
0
 private void RemovePrefixCore(string uriPrefix) => HttpEndPointManager.RemovePrefix(uriPrefix, this);
Example #7
0
 private void AddPrefixCore(string uriPrefix) => HttpEndPointManager.AddPrefix(uriPrefix, this);
Example #8
0
 private void Close(bool force)
 {
     CheckDisposed();
     HttpEndPointManager.RemoveListener(this);
     Cleanup(force);
 }