예제 #1
0
        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);
        }
예제 #2
0
 /// <summary>
 /// Closes connection.
 /// </summary>
 public void Dispose()
 {
     Channel.Dispose();
 }