Ejemplo n.º 1
0
        public ConsumerChannel(
            ulong id,
            uint messagePrefetchCount,
            AsyncQueue <MessagePackage> queue,
            IConnection connection,
            BatchHandler batchHandler,
            IEnumerable <IDecompressorFactory> decompressorFactories)
        {
            _id           = id;
            _queue        = queue;
            _connection   = connection;
            _batchHandler = batchHandler;

            _decompressors = new IDecompress[5];

            foreach (var decompressorFactory in decompressorFactories)
            {
                _decompressors[(int)decompressorFactory.CompressionType] = decompressorFactory.Create();
            }

            _lock = new AsyncLock();

            _cachedCommandFlow = new CommandFlow
            {
                ConsumerId     = id,
                MessagePermits = messagePrefetchCount
            };

            _sendWhenZero = 0;
            _firstFlow    = true;
        }
        /// <summary>Mark this as an outgoing command, and assign it to be sent on <paramref name="theNVT"/></summary>
        internal TelnetCommand OutgoingOn(TelnetNVT theNVT)
        {
            direction = CommandFlow.Outgoing;
            terminal  = theNVT;

            return(this);
        }
Ejemplo n.º 3
0
 public static BaseCommand ToBaseCommand(this CommandFlow value)
 {
     return(new BaseCommand
     {
         type = BaseCommand.Type.Flow,
         Flow = value
     });
 }
Ejemplo n.º 4
0
 public static BaseCommand AsBaseCommand(this CommandFlow command)
 {
     return(new BaseCommand
     {
         CommandType = BaseCommand.Type.Flow,
         Flow = command
     });
 }
        /// <summary>Mark this as a command incoming on <paramref name="theNVT"/>, and parse its contents</summary>
        internal TelnetCommand IncomingOn(TelnetNVT theNVT)
        {
            direction = CommandFlow.Incoming;
            terminal  = theNVT;
            Parse();
#if TelnetCommandLogging
            Debug.WriteLine("IN: " + humanReadableForm());
#endif
            return(this);
        }
Ejemplo n.º 6
0
 public ConsumerChannel(
     ulong id,
     uint messagePrefetchCount,
     AsyncQueue <MessagePackage> queue,
     IConnection connection,
     BatchHandler batchHandler)
 {
     _id                = id;
     _queue             = queue;
     _connection        = connection;
     _batchHandler      = batchHandler;
     _cachedCommandFlow = new CommandFlow {
         ConsumerId = id, MessagePermits = messagePrefetchCount
     };
     _sendWhenZero = 0;
     _firstFlow    = true;
 }
Ejemplo n.º 7
0
 public ConsumerStream(
     ulong id,
     uint messagePrefetchCount,
     IDequeue <MessagePackage> dequeue,
     Connection connection,
     IFaultStrategy faultStrategy,
     IConsumerProxy proxy,
     BatchHandler batchHandler)
 {
     _id                = id;
     _dequeue           = dequeue;
     _connection        = connection;
     _faultStrategy     = faultStrategy;
     _proxy             = proxy;
     _batchHandler      = batchHandler;
     _cachedCommandFlow = new CommandFlow {
         ConsumerId = id, MessagePermits = messagePrefetchCount
     };
     _sendWhenZero = 0;
     _firstFlow    = true;
 }
Ejemplo n.º 8
0
 public Task Send(CommandFlow command, CancellationToken cancellationToken)
 => Send(command.AsBaseCommand(), cancellationToken);
Ejemplo n.º 9
0
 public Builder()
 {
     _flow = new CommandFlow();
 }
Ejemplo n.º 10
0
 public async Task Send(CommandFlow command) => await Send(command.AsBaseCommand());