Exemplo n.º 1
0
        public void when_initializing_server_then_succeeds()
        {
            var configuration = new MqttConfiguration {
                BufferSize = 131072,
                Port       = MqttProtocol.DefaultNonSecurePort
            };
            var binding     = new ServerTcpBinding();
            var initializer = new MqttServerFactory(binding);
            var server      = initializer.CreateServer(configuration);

            Assert.NotNull(server);

            server.Stop();
        }
Exemplo n.º 2
0
        protected async Task <IMqttServer> GetServerAsync(IMqttAuthenticationProvider authenticationProvider = null)
        {
            try {
                LoadConfiguration();

                var binding     = new ServerTcpBinding();
                var initializer = new MqttServerFactory(binding, authenticationProvider);
                var server      = initializer.CreateServer(Configuration);

                server.Start();

                return(server);
            } catch (MqttException protocolEx) {
                if (protocolEx.InnerException is SocketException)
                {
                    return(await GetServerAsync());
                }
                else
                {
                    throw;
                }
            }
        }