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.
 
 
 
 

21 lines
638 B

  1. using MQTTnet.Extensions.Rpc.Options.TopicGeneration;
  2. using System;
  3. namespace MQTTnet.Extensions.Rpc.Options
  4. {
  5. public class DefaultMqttRpcClientTopicGenerationStrategy : IMqttRpcClientTopicGenerationStrategy
  6. {
  7. public MqttRpcTopicPair CreateRpcTopics(TopicGenerationContext context)
  8. {
  9. var requestTopic = $"MQTTnet.RPC/{Guid.NewGuid():N}/{context.MethodName}";
  10. var responseTopic = requestTopic + "/response";
  11. return new MqttRpcTopicPair
  12. {
  13. RequestTopic = requestTopic,
  14. ResponseTopic = responseTopic
  15. };
  16. }
  17. }
  18. }