您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DefaultMqttRpcClientTopicGenerationStrategy.cs 638 B

1234567891011121314151617181920
  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. }