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

87 行
2.4 KiB

  1. using System;
  2. namespace MQTTnet.Server
  3. {
  4. public class MqttServerOptionsBuilder
  5. {
  6. private readonly MqttServerOptions _options = new MqttServerOptions();
  7. public MqttServerOptionsBuilder WithConnectionBacklog(int value)
  8. {
  9. _options.ConnectionBacklog = value;
  10. return this;
  11. }
  12. public MqttServerOptionsBuilder WithDefaultCommunicationTimeout(TimeSpan value)
  13. {
  14. _options.DefaultCommunicationTimeout = value;
  15. return this;
  16. }
  17. public MqttServerOptionsBuilder WithDefaultEndpointPort(int value)
  18. {
  19. _options.DefaultEndpointOptions.Port = value;
  20. return this;
  21. }
  22. public MqttServerOptionsBuilder WithDefaultEndpoint()
  23. {
  24. _options.DefaultEndpointOptions.IsEnabled = true;
  25. return this;
  26. }
  27. public MqttServerOptionsBuilder WithoutDefaultEndpoint()
  28. {
  29. _options.DefaultEndpointOptions.IsEnabled = false;
  30. return this;
  31. }
  32. public MqttServerOptionsBuilder WithEncryptedEndpoint()
  33. {
  34. _options.TlsEndpointOptions.IsEnabled = true;
  35. return this;
  36. }
  37. public MqttServerOptionsBuilder WithoutEncryptedEndpoint()
  38. {
  39. _options.TlsEndpointOptions.IsEnabled = false;
  40. return this;
  41. }
  42. public MqttServerOptionsBuilder WithEncryptionCertificate(byte[] value)
  43. {
  44. _options.TlsEndpointOptions.Certificate = value;
  45. return this;
  46. }
  47. public MqttServerOptionsBuilder WithStorage(IMqttServerStorage value)
  48. {
  49. _options.Storage = value;
  50. return this;
  51. }
  52. public MqttServerOptionsBuilder WithConnectionValidator(Action<MqttConnectionValidatorContext> value)
  53. {
  54. _options.ConnectionValidator = value;
  55. return this;
  56. }
  57. public MqttServerOptionsBuilder WithApplicationMessageInterceptor(Action<MqttApplicationMessageInterceptorContext> value)
  58. {
  59. _options.ApplicationMessageInterceptor = value;
  60. return this;
  61. }
  62. public MqttServerOptionsBuilder WithSubscriptionInterceptor(Action<MqttSubscriptionInterceptorContext> value)
  63. {
  64. _options.SubscriptionInterceptor = value;
  65. return this;
  66. }
  67. public IMqttServerOptions Build()
  68. {
  69. return _options;
  70. }
  71. }
  72. }