Esempio n. 1
0
        public Responder(IResponderWorkerFactory responderWorkerFactory, IMessageSerialization messageSerialization, int minThreads = 1, int maxThreads = 1)
        {
            if (responderWorkerFactory == null) throw new ArgumentNullException("responderWorkerFactory");
            if (messageSerialization == null) throw new ArgumentNullException("messageSerialization");

            _responderWorkerFactory = responderWorkerFactory;
            _messageSerialization = messageSerialization;

            _disposeCancellationTokenSource = new CancellationTokenSource();
            _disposeCancellationToken = _disposeCancellationTokenSource.Token;

            _servers = new ConcurrentDictionary<RedFoxEndpoint, ISocketAccepter>();
            _clientSockets = new ConcurrentDictionary<ISocket, SenderReceiver>();
            _scheduler = new ResponderWorkerScheduler(minThreads, maxThreads);
            _scheduler.WorkerCompleted += SchedulerWorkerCompleted;

            _messageFrameCreator = new MessageFrameCreator(messageSerialization);
        }
Esempio n. 2
0
        public Responder(IResponderWorkerFactory responderWorkerFactory, IMessageSerialization messageSerialization, int minThreads = 1, int maxThreads = 1)
        {
            if (responderWorkerFactory == null)
            {
                throw new ArgumentNullException("responderWorkerFactory");
            }
            if (messageSerialization == null)
            {
                throw new ArgumentNullException("messageSerialization");
            }

            _responderWorkerFactory = responderWorkerFactory;
            _messageSerialization   = messageSerialization;

            _disposeCancellationTokenSource = new CancellationTokenSource();
            _disposeCancellationToken       = _disposeCancellationTokenSource.Token;

            _servers                    = new ConcurrentDictionary <RedFoxEndpoint, ISocketAccepter>();
            _clientSockets              = new ConcurrentDictionary <ISocket, SenderReceiver>();
            _scheduler                  = new ResponderWorkerScheduler(minThreads, maxThreads);
            _scheduler.WorkerCompleted += SchedulerWorkerCompleted;

            _messageFrameCreator = new MessageFrameCreator(messageSerialization);
        }