You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

19 lines
634 B

  1. using System;
  2. using System.Text;
  3. using System.Threading.Tasks;
  4. using MQTTnet.Protocol;
  5. namespace MQTTnet.Extensions.Rpc
  6. {
  7. public static class MqttRpcClientExtensions
  8. {
  9. public static Task<byte[]> ExecuteAsync(this IMqttRpcClient client, TimeSpan timeout, string methodName, string payload, MqttQualityOfServiceLevel qualityOfServiceLevel)
  10. {
  11. if (client == null) throw new ArgumentNullException(nameof(client));
  12. var buffer = Encoding.UTF8.GetBytes(payload ?? string.Empty);
  13. return client.ExecuteAsync(timeout, methodName, buffer, qualityOfServiceLevel);
  14. }
  15. }
  16. }