/// <inheritdoc/> /// <exception cref="ArgumentNullException"></exception> public Task PublishAsync(ManagedMqttApplicationMessage applicationMessage) { if (applicationMessage is null) { throw new ArgumentNullException(nameof(applicationMessage)); } return(InternalClient.PublishAsync(applicationMessage)); }
/// <inheritdoc/> /// <exception cref="ArgumentNullException"></exception> public Task <MqttClientPublishResult> PublishAsync(MqttApplicationMessage applicationMessage, CancellationToken cancellationToken) { if (applicationMessage is null) { throw new ArgumentNullException(nameof(applicationMessage)); } return(InternalClient.PublishAsync(applicationMessage, cancellationToken)); }
public async Task PublishMessage <T>(T messagePayload, string topic) where T : class { var appMessage = new MqttApplicationMessageBuilder() .WithContentType(typeof(T).Name) .WithPayload(JsonConvert.SerializeObject(messagePayload)) .WithTopic(topic) .Build(); await InternalClient.PublishAsync(appMessage, CancellationToken.None); }