예제 #1
0
        public async Task StartServerAsync()
        {
            try
            {
                var optionsBuilder = new MqttServerOptionsBuilder()
                                     .WithConnectionBacklog(100)
                                     .WithDefaultEndpointPort(1883);

                _mqttServer = new MqttFactory().CreateMqttServer();
                await _mqttServer.StartAsync(optionsBuilder.Build());
            }
            catch (Exception ex)
            {
                _logger.LogError("StartServerAsync error:\n" + ex.ToString());
                Console.ReadLine();
            }
        }
예제 #2
0
        private void btn_ServerStart_Click(object sender, EventArgs e)
        {
            IMqttServerOptions options = new MqttServerOptions()
            {
                ConnectionValidator = new MqttServerConnectionValidatorDelegate(ConnectEventAction),
            };

            server.StartAsync(options);
            if (server.IsStarted)
            {
                MessageBox.Show("Server Connect Success");
            }
            else
            {
                MessageBox.Show("Server Connect Fail");
            }
        }