コード例 #1
0
ファイル: HttpListener.cs プロジェクト: wcy-fmt/embedio
        /// <inheritdoc />
        public void Start()
        {
            if (IsListening)
            {
                return;
            }

            EndPointManager.AddListener(this).GetAwaiter().GetResult();
            IsListening = true;
        }
コード例 #2
0
        /// <summary>
        /// Starts this listener.
        /// </summary>
        public void Start()
        {
            if (IsListening)
            {
                return;
            }

            EndPointManager.AddListener(this);
            IsListening = true;
        }
コード例 #3
0
ファイル: HttpListener.cs プロジェクト: kobeyoung81/JBServer
        /// <summary>
        /// Starts this listener.
        /// </summary>
        public void Start()
        {
            CheckDisposed();
            if (IsListening)
            {
                return;
            }

            EndPointManager.AddListener(this);
            IsListening = true;
        }
コード例 #4
0
        public new void Add(string uriPrefix)
        {
            ListenerPrefix.CheckUri(uriPrefix);
            if (Contains(uriPrefix))
            {
                return;
            }

            base.Add(uriPrefix);
            if (_listener.IsListening)
            {
                EndPointManager.AddPrefix(uriPrefix, _listener).GetAwaiter().GetResult();
            }
        }
コード例 #5
0
        /// <summary>
        /// Adds the specified URI prefix.
        /// </summary>
        /// <param name="uriPrefix">The URI prefix.</param>
        public void Add(string uriPrefix)
        {
            ListenerPrefix.CheckUri(uriPrefix);
            if (_prefixes.Contains(uriPrefix))
            {
                return;
            }

            _prefixes.Add(uriPrefix);
            if (_listener.IsListening)
            {
                EndPointManager.AddPrefix(uriPrefix, _listener);
            }
        }
コード例 #6
0
        /// <summary>
        /// Removes the specified URI prefix.
        /// </summary>
        /// <param name="uriPrefix">The URI prefix.</param>
        /// <returns>True if "uriPrefix" was removed; otherwise, false</returns>
        /// <exception cref="System.ArgumentNullException">uriPrefix</exception>
        public new bool Remove(string uriPrefix)
        {
            if (uriPrefix == null)
            {
                throw new ArgumentNullException(nameof(uriPrefix));
            }

            var result = base.Remove(uriPrefix);

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

            return(result);
        }
コード例 #7
0
        /// <summary>
        /// Removes the specified URI prefix.
        /// </summary>
        /// <param name="uriPrefix">The URI prefix.</param>
        /// <returns>True if "uriPrefix" was removed; otherwise, false</returns>
        /// <exception cref="System.ArgumentNullException">uriPrefix</exception>
        public bool Remove(string uriPrefix)
        {
            _listener.CheckDisposed();
            if (uriPrefix == null)
            {
                throw new ArgumentNullException(nameof(uriPrefix));
            }

            var result = _prefixes.Remove(uriPrefix);

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

            return(result);
        }
コード例 #8
0
        private void CheckIfRemove()
        {
            if (_prefixes.Count > 0)
            {
                return;
            }

            var list = _unhandled;

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

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

            EndPointManager.RemoveEndPoint(this, _endpoint);
        }
コード例 #9
0
        private void Close(bool closeExisting)
        {
            EndPointManager.RemoveListener(this);

            var conns = new List <HttpConnection>();

            lock (_connections.SyncRoot)
            {
                var keys       = _connections.Keys;
                var connsArray = new HttpConnection[keys.Count];
                keys.CopyTo(connsArray, 0);
                _connections.Clear();
                conns.AddRange(connsArray);
            }

            for (var i = conns.Count - 1; i >= 0; i--)
            {
                conns[i].Close(true);
            }

            if (closeExisting == false)
            {
                return;
            }

            while (_ctxQueue.IsEmpty == false)
            {
                foreach (var key in _ctxQueue.Keys.Select(x => x).ToList())
                {
                    if (_ctxQueue.TryGetValue(key, out var context))
                    {
                        context.Connection.Close(true);
                    }
                }
            }
        }
コード例 #10
0
ファイル: HttpListener.cs プロジェクト: kobeyoung81/JBServer
 private async Task CloseAsync(bool force)
 {
     CheckDisposed();
     EndPointManager.RemoveListener(this);
     await CleanupAsync(force);
 }
コード例 #11
0
ファイル: HttpListener.cs プロジェクト: pwlstation/embedio
 void Close(bool force)
 {
     CheckDisposed();
     EndPointManager.RemoveListener(this);
     Cleanup(force);
 }