浏览代码

Update version info. Fix typo. Add MqttServerOptionsBuilder.

release/3.x.x
Christian Kratky 7 年前
父节点
当前提交
e54b4f58df
共有 8 个文件被更改,包括 122 次插入10 次删除
  1. +3
    -4
      Build/MQTTnet.AspNetCore.nuspec
  2. +1
    -1
      Frameworks/MQTTnet.NetStandard/Implementations/MqttWebSocketChannel.cs
  3. +1
    -1
      MQTTnet.Core/Server/MqttClientSubscriptionsManager.cs
  4. +25
    -0
      MQTTnet.Core/Server/MqttConnectionValidatorContext.cs
  5. +2
    -2
      MQTTnet.Core/Server/MqttServerOptions.cs
  6. +88
    -0
      MQTTnet.Core/Server/MqttServerOptionsBuilder.cs
  7. +1
    -1
      Tests/MQTTnet.TestApp.AspNetCore2/MQTTnet.TestApp.AspNetCore2.csproj
  8. +1
    -1
      Tests/MQTTnet.TestApp.NetCore/ServerTest.cs

+ 3
- 4
Build/MQTTnet.AspNetCore.nuspec 查看文件

@@ -2,7 +2,7 @@
<package >
<metadata>
<id>MQTTnet.AspNetCore</id>
<version>2.5.2</version>
<version>2.5.3</version>
<authors>Christian Kratky</authors>
<owners>Christian Kratky</owners>
<licenseUrl>https://github.com/chkr1011/MQTTnet/blob/master/LICENSE</licenseUrl>
@@ -10,14 +10,13 @@
<iconUrl>https://raw.githubusercontent.com/chkr1011/MQTTnet/master/Images/Logo_128x128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This is a support library to integrate MQTTnet into AspNetCore.</description>
<releaseNotes>* Updated to MQTTnet 2.5.2.
* Fixed WebSocket protocol negotiation.
<releaseNotes>* Updated to MQTTnet 2.5.3.
</releaseNotes>
<copyright>Copyright Christian Kratky 2016-2017</copyright>
<tags>MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin</tags>
<dependencies>
<group targetFramework="netstandard2.0">
<dependency id="MQTTnet" version="2.5.2" />
<dependency id="MQTTnet" version="2.5.3-rc1" />
</group>
</dependencies>
</metadata>


+ 1
- 1
Frameworks/MQTTnet.NetStandard/Implementations/MqttWebSocketChannel.cs 查看文件

@@ -31,7 +31,7 @@ namespace MQTTnet.Implementations
var uri = _options.Uri;
if (!uri.StartsWith("ws://", StringComparison.OrdinalIgnoreCase) && !uri.StartsWith("wss://", StringComparison.OrdinalIgnoreCase))
{
if (!_options.TlsOptions.UseTls)
if (_options.TlsOptions?.UseTls == false)
{
uri = "ws://" + uri;
}


+ 1
- 1
MQTTnet.Core/Server/MqttClientSubscriptionsManager.cs 查看文件

@@ -27,7 +27,7 @@ namespace MQTTnet.Core.Server
foreach (var topicFilter in subscribePacket.TopicFilters)
{
var interceptorContext = new MqttSubscriptionInterceptorContext(clientId, topicFilter);
_options.SubscriptionsInterceptor?.Invoke(interceptorContext);
_options.SubscriptionInterceptor?.Invoke(interceptorContext);
responsePacket.SubscribeReturnCodes.Add(interceptorContext.AcceptSubscription ? MqttSubscribeReturnCode.SuccessMaximumQoS1 : MqttSubscribeReturnCode.Failure);
if (interceptorContext.CloseConnection)


+ 25
- 0
MQTTnet.Core/Server/MqttConnectionValidatorContext.cs 查看文件

@@ -0,0 +1,25 @@
using MQTTnet.Core.Protocol;

namespace MQTTnet.Core.Server
{
public class MqttConnectionValidatorContext
{
public MqttConnectionValidatorContext(string clientId, string username, string password, MqttApplicationMessage willMessage)
{
ClientId = clientId;
Username = username;
Password = password;
WillMessage = willMessage;
}

public string ClientId { get; }

public string Username { get; }

public string Password { get; }

public MqttApplicationMessage WillMessage { get; }

public MqttConnectReturnCode ReturnCode { get; set; } = MqttConnectReturnCode.ConnectionAccepted;
}
}

+ 2
- 2
MQTTnet.Core/Server/MqttServerOptions.cs 查看文件

@@ -11,14 +11,14 @@ namespace MQTTnet.Core.Server
public MqttServerTlsEndpointOptions TlsEndpointOptions { get; } = new MqttServerTlsEndpointOptions();

public int ConnectionBacklog { get; set; } = 10;
public TimeSpan DefaultCommunicationTimeout { get; set; } = TimeSpan.FromSeconds(15);

public Func<MqttConnectPacket, MqttConnectReturnCode> ConnectionValidator { get; set; }

public Action<MqttApplicationMessageInterceptorContext> ApplicationMessageInterceptor { get; set; }

public Action<MqttSubscriptionInterceptorContext> SubscriptionsInterceptor { get; set; }
public Action<MqttSubscriptionInterceptorContext> SubscriptionInterceptor { get; set; }

public IMqttServerStorage Storage { get; set; }
}


+ 88
- 0
MQTTnet.Core/Server/MqttServerOptionsBuilder.cs 查看文件

@@ -0,0 +1,88 @@
using System;
using MQTTnet.Core.Packets;
using MQTTnet.Core.Protocol;

namespace MQTTnet.Core.Server
{
public class MqttServerOptionsBuilder
{
private readonly MqttServerOptions _options = new MqttServerOptions();

public MqttServerOptionsBuilder WithConnectionBacklog(int value)
{
_options.ConnectionBacklog = value;
return this;
}

public MqttServerOptionsBuilder WithDefaultCommunicationTimeout(TimeSpan value)
{
_options.DefaultCommunicationTimeout = value;
return this;
}

public MqttServerOptionsBuilder WithDefaultEndpointPort(int value)
{
_options.DefaultEndpointOptions.Port = value;
return this;
}

public MqttServerOptionsBuilder WithDefaultEndpoint()
{
_options.DefaultEndpointOptions.IsEnabled = true;
return this;
}

public MqttServerOptionsBuilder WithoutDefaultEndpoint()
{
_options.DefaultEndpointOptions.IsEnabled = false;
return this;
}

public MqttServerOptionsBuilder WithEncryptedEndpoint()
{
_options.TlsEndpointOptions.IsEnabled = true;
return this;
}

public MqttServerOptionsBuilder WithoutEncryptedEndpoint()
{
_options.TlsEndpointOptions.IsEnabled = false;
return this;
}

public MqttServerOptionsBuilder WithEncryptionCertificate(byte[] value)
{
_options.TlsEndpointOptions.Certificate = value;
return this;
}

public MqttServerOptionsBuilder WithStorage(IMqttServerStorage value)
{
_options.Storage = value;
return this;
}

public MqttServerOptionsBuilder WithConnectionValidator(Func<MqttConnectPacket, MqttConnectReturnCode> value)
{
_options.ConnectionValidator = value;
return this;
}

public MqttServerOptionsBuilder WithApplicationMessageInterceptor(Action<MqttApplicationMessageInterceptorContext> value)
{
_options.ApplicationMessageInterceptor = value;
return this;
}

public MqttServerOptionsBuilder WithSubscriptionInterceptor(Action<MqttSubscriptionInterceptorContext> value)
{
_options.SubscriptionInterceptor = value;
return this;
}

public MqttServerOptions Build()
{
return _options;
}
}
}

+ 1
- 1
Tests/MQTTnet.TestApp.AspNetCore2/MQTTnet.TestApp.AspNetCore2.csproj 查看文件

@@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
Tests/MQTTnet.TestApp.NetCore/ServerTest.cs 查看文件

@@ -40,7 +40,7 @@ namespace MQTTnet.TestApp.NetCore
context.ApplicationMessage.Payload = Encoding.UTF8.GetBytes(DateTime.Now.ToString("O"));
}
},
SubscriptionsInterceptor = context =>
SubscriptionInterceptor = context =>
{
if (context.TopicFilter.Topic.StartsWith("admin/foo/bar") && context.ClientId != "theAdmin")
{


正在加载...
取消
保存