Пример #1
0
        public async Task <IMqttServer> StartServerAsync(MqttServerOptionsBuilder options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (Server != null)
            {
                throw new InvalidOperationException("Server already started.");
            }

            Server = new TestServerWrapper(_mqttFactory.CreateMqttServer(ServerLogger), TestContext, this);

            options.WithDefaultEndpointPort(ServerPort);

            await Server.StartAsync(options.Build()).ConfigureAwait(false);

            return(Server);
        }