public async Task Publish(string topic, string Payload, int qos = 0, bool retain = false) { if (topic == null) { throw new ArgumentNullException(nameof(topic)); } await _mqttService.Publish(new MqttPublishParameters <string>() { Payload = Payload, QualityOfServiceLevel = (MqttQualityOfServiceLevel)qos, Retain = retain, Topic = topic }); }
private void OnApplicationMessageReceived(MqttApplicationMessageReceivedEventArgs e) { Task.Run(async() => { await _mqttService.Publish(new MqttPublishParameters <byte[]> { Topic = e.ApplicationMessage.Topic, Payload = e.ApplicationMessage.Payload, QualityOfServiceLevel = e.ApplicationMessage.QualityOfServiceLevel, Retain = e.ApplicationMessage.Retain }); }); }