// constructors public BinaryConnection(ServerId serverId, EndPoint endPoint, ConnectionSettings settings, IStreamFactory streamFactory, IConnectionInitializer connectionInitializer, IEventSubscriber eventSubscriber) { Ensure.IsNotNull(serverId, nameof(serverId)); _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); _settings = Ensure.IsNotNull(settings, nameof(settings)); _streamFactory = Ensure.IsNotNull(streamFactory, nameof(streamFactory)); _connectionInitializer = Ensure.IsNotNull(connectionInitializer, nameof(connectionInitializer)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _connectionId = new ConnectionId(serverId); _receiveLock = new SemaphoreSlim(1); _sendLock = new SemaphoreSlim(1); _state = new InterlockedInt32(State.Initial); _commandEventHelper = new CommandEventHelper(eventSubscriber); eventSubscriber.TryGetEventHandler(out _failedEventHandler); eventSubscriber.TryGetEventHandler(out _closingEventHandler); eventSubscriber.TryGetEventHandler(out _closedEventHandler); eventSubscriber.TryGetEventHandler(out _openingEventHandler); eventSubscriber.TryGetEventHandler(out _openedEventHandler); eventSubscriber.TryGetEventHandler(out _failedOpeningEventHandler); eventSubscriber.TryGetEventHandler(out _receivingMessageEventHandler); eventSubscriber.TryGetEventHandler(out _receivedMessageEventHandler); eventSubscriber.TryGetEventHandler(out _failedReceivingMessageEventHandler); eventSubscriber.TryGetEventHandler(out _sendingMessagesEventHandler); eventSubscriber.TryGetEventHandler(out _sentMessagesEventHandler); eventSubscriber.TryGetEventHandler(out _failedSendingMessagesEvent); _compressorSource = new CompressorSource(settings.Compressors); }
// constructors public BinaryConnection(ServerId serverId, EndPoint endPoint, ConnectionSettings settings, IStreamFactory streamFactory, IConnectionInitializer connectionInitializer, IEventSubscriber eventSubscriber) { Ensure.IsNotNull(serverId, nameof(serverId)); _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); _settings = Ensure.IsNotNull(settings, nameof(settings)); _streamFactory = Ensure.IsNotNull(streamFactory, nameof(streamFactory)); _connectionInitializer = Ensure.IsNotNull(connectionInitializer, nameof(connectionInitializer)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _backgroundTaskCancellationTokenSource = new CancellationTokenSource(); _backgroundTaskCancellationToken = _backgroundTaskCancellationTokenSource.Token; _connectionId = new ConnectionId(serverId); _receiveLock = new SemaphoreSlim(1); _sendLock = new SemaphoreSlim(1); _state = new InterlockedInt32(State.Initial); _commandEventHelper = new CommandEventHelper(eventSubscriber); eventSubscriber.TryGetEventHandler(out _failedEventHandler); eventSubscriber.TryGetEventHandler(out _closingEventHandler); eventSubscriber.TryGetEventHandler(out _closedEventHandler); eventSubscriber.TryGetEventHandler(out _openingEventHandler); eventSubscriber.TryGetEventHandler(out _openedEventHandler); eventSubscriber.TryGetEventHandler(out _failedOpeningEventHandler); eventSubscriber.TryGetEventHandler(out _receivingMessageEventHandler); eventSubscriber.TryGetEventHandler(out _receivedMessageEventHandler); eventSubscriber.TryGetEventHandler(out _failedReceivingMessageEventHandler); eventSubscriber.TryGetEventHandler(out _sendingMessagesEventHandler); eventSubscriber.TryGetEventHandler(out _sentMessagesEventHandler); eventSubscriber.TryGetEventHandler(out _failedSendingMessagesEvent); }