Exemplo n.º 1
0
        public MqttBroker(ILogger logger, MqttOptions options)
        {
            MqttAsyncTcpSender.Init(options);

            this.logger            = logger;
            this.uacManager        = new MqttUacManager();
            this.rawMessageManager = new MqttRawMessageManager(options);
            this.asyncTcpReceiver  = new MqttAsyncTcpReceiver(rawMessageManager);
            this.connectionManager = new MqttClientConnectionManager(logger, options, asyncTcpReceiver);

            var numberOfProcessingManagersNeeded = options.MaxConnections / options.ConnectionsPrProcessingManager;

            this.processingManagers = new MqttClientConnectionProcessingManager[numberOfProcessingManagersNeeded];
            for (var i = 0; i < processingManagers.Length; i++)
            {
                processingManagers[i] = new MqttClientConnectionProcessingManager(logger, connectionManager, uacManager, asyncTcpReceiver);
            }

            this.processingLoadbalancer = new MqttProcessingLoadbalancer(logger, processingManagers);

            this.socketListener = new MqttAsyncTcpSocketListener(processingLoadbalancer, connectionManager, options);
        }