internal void RemoveConnection(HttpConnection cnc) { _connections.Remove(cnc); }
void Cleanup(bool closeExisting) { lock (_registry) { if (closeExisting) { // Need to copy this since closing will call UnregisterContext var keys = _registry.Keys; var all = new HttpListenerContext[keys.Count]; keys.CopyTo(all, 0); _registry.Clear(); for (var i = all.Length - 1; i >= 0; i--) all[i].Connection.Close(true); } lock (_connections.SyncRoot) { var keys = _connections.Keys; var conns = new HttpConnection[keys.Count]; keys.CopyTo(conns, 0); _connections.Clear(); for (var i = conns.Length - 1; i >= 0; i--) conns[i].Close(true); } lock (_ctxQueue) { var ctxs = (HttpListenerContext[])_ctxQueue.ToArray(typeof(HttpListenerContext)); _ctxQueue.Clear(); for (var i = ctxs.Length - 1; i >= 0; i--) ctxs[i].Connection.Close(true); } lock (_waitQueue) { Exception exc = new ObjectDisposedException("listener"); foreach (ListenerAsyncResult ares in _waitQueue) { ares.Complete(exc); } _waitQueue.Clear(); } } }
internal void AddConnection(HttpConnection cnc) { _connections[cnc] = cnc; }
internal HttpListenerContext(HttpConnection cnc) { Connection = cnc; Request = new HttpListenerRequest(this); Response = new HttpListenerResponse(this); }
internal void RemoveConnection(HttpConnection cnc) => _connections.TryRemove(cnc, out _);
internal void AddConnection(HttpConnection cnc) => _connections[cnc] = cnc;