private void OnChannelOpen(IDuplexChannel channel) { if (_connections.Count >= _config.MaxConnections) { channel.Dispose(); return; } var connection = new RemoteConnection(channel, GetOperationDispatcher(), _connectionConfig); var channelId = channel.Id; connection.Closed += () => HandleConnectionClose(channelId); if (OnConnectionInitialize != null) { OnConnectionInitialize(connection); } if (!_connections.TryAdd(channelId, connection)) { channel.Dispose(); } HandleConnectionOpen(connection); }
/// <summary> /// Closes connection. /// </summary> public void Dispose() { Channel.Dispose(); }