|
|
@@ -184,10 +184,10 @@ namespace YSAI.Mqtt.service
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
private Task MqttServer_ValidatingConnectionAsync(ValidatingConnectionEventArgs arg)
|
|
|
{
|
|
|
- return Task.Run((Action)(() =>
|
|
|
+ return Task.Run(() =>
|
|
|
{
|
|
|
//验证账号密码是否正确
|
|
|
- if (!arg.UserName.Equals((string?)basics.UserName) || !arg.Password.Equals(basics.Password))
|
|
|
+ if (arg.UserName != basics.UserName || arg.Password != basics.Password)
|
|
|
{
|
|
|
arg.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.BadUserNameOrPassword;
|
|
|
OnEventHandler(this, new EventResult(false, $"[ {Steps.客户端身份验证事件} ]( {arg.ClientId} ) 身份验证异常:{arg.ReasonCode}", arg.ClientId, ResultType.String));
|
|
|
@@ -197,7 +197,7 @@ namespace YSAI.Mqtt.service
|
|
|
arg.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.Success;
|
|
|
OnEventHandler(this, new EventResult(true, $"[ {Steps.客户端身份验证事件} ]( {arg.ClientId} ) 身份验证成功", arg.ClientId, ResultType.String));
|
|
|
}
|
|
|
- }));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
#endregion 私有函数
|