public ReceiveMessageHelper(BinaryConnection connection, int responseTo, MessageEncoderSettings messageEncoderSettings, ICompressorSource compressorSource)
 {
     _compressorSource       = compressorSource;
     _connection             = connection;
     _responseTo             = responseTo;
     _messageEncoderSettings = messageEncoderSettings;
 }
        // 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);
        }
Example #3
0
 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="BinaryMessageEncoderFactory"/> class.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="encoderSettings">The encoder settings.</param>
 /// <param name="compressorSource">The compressor source.</param>
 public BinaryMessageEncoderFactory(
     Stream stream,
     MessageEncoderSettings encoderSettings,
     ICompressorSource compressorSource = null)
 {
     _compressorSource = compressorSource;
     _stream           = Ensure.IsNotNull(stream, nameof(stream));
     _encoderSettings  = encoderSettings; // can be null
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompressedMessageBinaryEncoder" /> class.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="originalEncoderSelector">The original encoder selector.</param>
 /// <param name="compressorSource">The compressor source.</param>
 /// <param name="encoderSettings">The encoder settings.</param>
 public CompressedMessageBinaryEncoder(
     Stream stream,
     IMessageEncoderSelector originalEncoderSelector,
     ICompressorSource compressorSource,
     MessageEncoderSettings encoderSettings)
     : base(stream, encoderSettings)
 {
     _compressorSource        = Ensure.IsNotNull(compressorSource, nameof(compressorSource));
     _encoderSettings         = encoderSettings; // can be null
     _originalEncoderSelector = originalEncoderSelector;
 }