public void Disconnect(IConnection connection) { IClient key = connection.Client; if (this._clients.ContainsKey(key)) { Exception exception; CopyOnWriteArraySet <IConnection> set = this._clients[key]; set.Remove(connection); IScopeHandler handler = null; if (this.HasHandler) { handler = this.Handler; try { handler.Disconnect(connection, this); } catch (Exception exception1) { exception = exception1; if ((log != null) && log.get_IsErrorEnabled()) { log.Error(string.Concat(new object[] { "Error while executing \"disconnect\" for connection ", connection, " on handler ", handler }), exception); } } } if (set.Count == 0) { this._clients.Remove(key); if (handler != null) { try { handler.Leave(key, this); } catch (Exception exception2) { exception = exception2; if ((log != null) && log.get_IsErrorEnabled()) { log.Error(string.Concat(new object[] { "Error while executing \"leave\" for client ", key, " on handler ", handler }), exception); } } } } this.RemoveEventListener(connection); } if (base.HasParent) { this.Parent.Disconnect(connection); } }
public void Disconnect(IConnection connection) { // We call the disconnect handlers in reverse order they were called // during connection, i.e. roomDisconnect is called before // appDisconnect. IClient client = connection.Client; if (_clients.ContainsKey(client)) { CopyOnWriteArraySet <IConnection> connections = _clients[client]; connections.Remove(connection); IScopeHandler handler = null; if (HasHandler) { handler = this.Handler; try { handler.Disconnect(connection, this); } catch (Exception) { } } if (connections.Count == 0) { _clients.Remove(client); if (handler != null) { try { // there may be a timeout here ? handler.Leave(client, this); } catch (Exception) { } } } RemoveEventListener(connection); } if (HasParent) { this.Parent.Disconnect(connection); } }
/// <summary> /// Disconnects the specified connection. /// </summary> /// <param name="connection">The connection.</param> public void Disconnect(IConnection connection) { // We call the disconnect handlers in reverse order they were called during connection, i.e. roomDisconnect is called before appDisconnect. IClient client = connection.Client; if (client == null) { // Early bail out RemoveEventListener(connection); _connectionStats.Decrement(); if (HasParent) { Parent.Disconnect(connection); } return; } if (_clients.ContainsKey(client)) { CopyOnWriteArraySet <IConnection> connections = _clients[client]; connections.Remove(connection); IScopeHandler handler = null; if (HasHandler) { handler = Handler; try { handler.Disconnect(connection, this); } catch (Exception ex) { #if !SILVERLIGHT if (log != null && log.IsErrorEnabled) { log.Error("Error while executing \"disconnect\" for connection " + connection + " on handler " + handler, ex); } #endif } } if (connections.Count == 0) { _clients.Remove(client); _clientStats.Decrement(); if (handler != null) { try { // there may be a timeout here ? handler.Leave(client, this); } catch (Exception ex) { #if !SILVERLIGHT if (log != null && log.IsErrorEnabled) { log.Error("Error while executing \"leave\" for client " + client + " on handler " + handler, ex); } #endif } } } RemoveEventListener(connection); _connectionStats.Decrement(); } if (HasParent) { Parent.Disconnect(connection); } }