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.
 
 
 
 

23 lines
834 B

  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using MQTTnet.Protocol;
  8. namespace MQTTnet.Extensions.Rpc
  9. {
  10. public static class MqttRpcClientExtensions
  11. {
  12. public static Task<byte[]> ExecuteAsync(this MqttRpcClient client, TimeSpan timeout, string methodName, string payload, MqttQualityOfServiceLevel qualityOfServiceLevel)
  13. {
  14. if (client == null) throw new ArgumentNullException(nameof(client));
  15. var buffer = Encoding.UTF8.GetBytes(payload ?? string.Empty);
  16. return client.ExecuteAsync(timeout, methodName, buffer, qualityOfServiceLevel);
  17. }
  18. }
  19. }