소스 검색

dont allow publish before the client is started and adjusted testclient accordingly

release/3.x.x
JanEggers 5 년 전
부모
커밋
328ffc734f
2개의 변경된 파일4개의 추가작업 그리고 5개의 파일을 삭제
  1. +1
    -2
      Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs
  2. +3
    -3
      Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs

+ 1
- 2
Source/MQTTnet.Extensions.ManagedClient/ManagedMqttClient.cs 파일 보기

@@ -49,8 +49,6 @@ namespace MQTTnet.Extensions.ManagedClient

if (logger == null) throw new ArgumentNullException(nameof(logger));
_logger = logger.CreateChildLogger(nameof(ManagedMqttClient));

Options = new ManagedMqttClientOptions();
}

public bool IsConnected => _mqttClient.IsConnected;
@@ -150,6 +148,7 @@ namespace MQTTnet.Extensions.ManagedClient
ThrowIfDisposed();

if (applicationMessage == null) throw new ArgumentNullException(nameof(applicationMessage));
if (Options == null) throw new InvalidOperationException("call StartAsync before publishing messages");

MqttTopicValidator.ThrowIfInvalid(applicationMessage.ApplicationMessage.Topic);



+ 3
- 3
Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs 파일 보기

@@ -40,11 +40,11 @@ namespace MQTTnet.TestApp.NetCore
Console.WriteLine(">> RECEIVED: " + e.ApplicationMessage.Topic);
});

await managedClient.PublishAsync(builder => builder.WithTopic("Step").WithPayload("1"));
await managedClient.PublishAsync(builder => builder.WithTopic("Step").WithPayload("2").WithAtLeastOnceQoS());

await managedClient.StartAsync(options);

await managedClient.PublishAsync(builder => builder.WithTopic("Step").WithPayload("1"));
await managedClient.PublishAsync(builder => builder.WithTopic("Step").WithPayload("2").WithAtLeastOnceQoS());
await managedClient.SubscribeAsync(new TopicFilter { Topic = "xyz", QualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce });
await managedClient.SubscribeAsync(new TopicFilter { Topic = "abc", QualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce });



불러오는 중...
취소
저장