Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
MQTTnet
提交
449624fd
MQTTnet
项目概览
dotNET Platform
/
MQTTnet
大约 1 年 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MQTTnet
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
449624fd
编写于
5月 06, 2023
作者:
C
Christian
提交者:
GitHub
5月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Expose proper connect result in clients Disconnected event (#1728)
上级
99f4f460
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
205 addition
and
102 deletion
+205
-102
.github/workflows/ReleaseNotes.md
.github/workflows/ReleaseNotes.md
+1
-0
Source/MQTTnet.Extensions.ManagedClient/MqttFactoryExtensions.cs
...MQTTnet.Extensions.ManagedClient/MqttFactoryExtensions.cs
+21
-6
Source/MQTTnet.Tests/Clients/ManagedMqttClient/ManagedMqttClient_Tests.cs
...ests/Clients/ManagedMqttClient/ManagedMqttClient_Tests.cs
+32
-0
Source/MQTTnet.Tests/Clients/MqttClient/MqttClient_Connection_Tests.cs
...t.Tests/Clients/MqttClient/MqttClient_Connection_Tests.cs
+2
-0
Source/MQTTnet.Tests/Mockups/TestEnvironment.cs
Source/MQTTnet.Tests/Mockups/TestEnvironment.cs
+1
-1
Source/MQTTnet/Client/Internal/MqttClientEvents.cs
Source/MQTTnet/Client/Internal/MqttClientEvents.cs
+18
-0
Source/MQTTnet/Client/Internal/MqttClientResultFactory.cs
Source/MQTTnet/Client/Internal/MqttClientResultFactory.cs
+13
-0
Source/MQTTnet/Client/MqttClient.cs
Source/MQTTnet/Client/MqttClient.cs
+117
-95
未找到文件。
.github/workflows/ReleaseNotes.md
浏览文件 @
449624fd
*
[Core] Add validation of maximum string lengths (#1718).
*
[Client] Added overloads for setting packet payload and will payload (#1720).
*
[Client] The proper connect result is now exposed in the _Disconnected_ event when authentication fails (#1139).
*
[Server] Improved performance by changing internal locking strategy for subscriptions (#1716, thanks to @zeheng).
Source/MQTTnet.Extensions.ManagedClient/MqttFactoryExtensions.cs
浏览文件 @
449624fd
...
...
@@ -12,7 +12,10 @@ namespace MQTTnet.Extensions.ManagedClient
{
public
static
IManagedMqttClient
CreateManagedMqttClient
(
this
MqttFactory
factory
,
IMqttClient
mqttClient
=
null
)
{
if
(
factory
==
null
)
throw
new
ArgumentNullException
(
nameof
(
factory
));
if
(
factory
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
factory
));
}
if
(
mqttClient
==
null
)
{
...
...
@@ -24,10 +27,22 @@ namespace MQTTnet.Extensions.ManagedClient
public
static
IManagedMqttClient
CreateManagedMqttClient
(
this
MqttFactory
factory
,
IMqttNetLogger
logger
)
{
if
(
factory
==
null
)
throw
new
ArgumentNullException
(
nameof
(
factory
));
if
(
logger
==
null
)
throw
new
ArgumentNullException
(
nameof
(
logger
));
if
(
factory
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
factory
));
}
if
(
logger
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
logger
));
}
return
new
ManagedMqttClient
(
factory
.
CreateMqttClient
(
logger
),
logger
);
}
public
static
ManagedMqttClientOptionsBuilder
CreateManagedMqttClientOptionsBuilder
(
this
MqttFactory
_
)
{
return
new
ManagedMqttClientOptionsBuilder
();
}
}
}
\ No newline at end of file
Source/MQTTnet.Tests/Clients/ManagedMqttClient/ManagedMqttClient_Tests.cs
浏览文件 @
449624fd
...
...
@@ -22,6 +22,38 @@ namespace MQTTnet.Tests.Clients.ManagedMqttClient
[
TestClass
]
public
sealed
class
ManagedMqttClient_Tests
:
BaseTestClass
{
[
TestMethod
]
public
async
Task
Expose_Custom_Connection_Error
()
{
using
(
var
testEnvironment
=
CreateTestEnvironment
())
{
var
server
=
await
testEnvironment
.
StartServer
();
server
.
ValidatingConnectionAsync
+=
args
=>
{
args
.
ReasonCode
=
MqttConnectReasonCode
.
BadUserNameOrPassword
;
return
CompletedTask
.
Instance
;
};
var
managedClient
=
testEnvironment
.
Factory
.
CreateManagedMqttClient
();
MqttClientDisconnectedEventArgs
disconnectedArgs
=
null
;
managedClient
.
DisconnectedAsync
+=
args
=>
{
disconnectedArgs
=
args
;
return
CompletedTask
.
Instance
;
};
var
clientOptions
=
testEnvironment
.
Factory
.
CreateManagedMqttClientOptionsBuilder
().
WithClientOptions
(
testEnvironment
.
CreateDefaultClientOptions
()).
Build
();
await
managedClient
.
StartAsync
(
clientOptions
);
await
LongTestDelay
();
Assert
.
IsNotNull
(
disconnectedArgs
);
Assert
.
AreEqual
(
MqttClientConnectResultCode
.
BadUserNameOrPassword
,
disconnectedArgs
.
ConnectResult
.
ResultCode
);
}
}
[
TestMethod
]
public
async
Task
Receive_While_Not_Cleanly_Disconnected
()
{
...
...
Source/MQTTnet.Tests/Clients/MqttClient/MqttClient_Connection_Tests.cs
浏览文件 @
449624fd
...
...
@@ -127,6 +127,8 @@ namespace MQTTnet.Tests.Clients.MqttClient
// Perform a clean disconnect.
await
client
.
DisconnectAsync
(
disconnectOptions
);
await
LongTestDelay
();
Assert
.
IsNotNull
(
eventArgs
);
Assert
.
AreEqual
(
MqttDisconnectReasonCode
.
MessageRateTooHigh
,
eventArgs
.
ReasonCode
);
}
...
...
Source/MQTTnet.Tests/Mockups/TestEnvironment.cs
浏览文件 @
449624fd
...
...
@@ -245,7 +245,7 @@ namespace MQTTnet.Tests.Mockups
public
MqttClientOptionsBuilder
CreateDefaultClientOptionsBuilder
()
{
return
Factory
.
CreateClientOptionsBuilder
().
WithProtocolVersion
(
_protocolVersion
).
WithTcpServer
(
"127.0.0.1"
,
ServerPort
);
return
Factory
.
CreateClientOptionsBuilder
().
WithProtocolVersion
(
_protocolVersion
).
WithTcpServer
(
"127.0.0.1"
,
ServerPort
)
.
WithClientId
(
TestContext
.
TestName
+
"_"
+
Guid
.
NewGuid
())
;
}
public
ILowLevelMqttClient
CreateLowLevelClient
()
...
...
Source/MQTTnet/Client/Internal/MqttClientEvents.cs
0 → 100644
浏览文件 @
449624fd
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
MQTTnet.Diagnostics
;
using
MQTTnet.Internal
;
namespace
MQTTnet.Client.Internal
{
public
sealed
class
MqttClientEvents
{
public
AsyncEvent
<
MqttApplicationMessageReceivedEventArgs
>
ApplicationMessageReceivedEvent
{
get
;
}
=
new
AsyncEvent
<
MqttApplicationMessageReceivedEventArgs
>();
public
AsyncEvent
<
MqttClientConnectedEventArgs
>
ConnectedEvent
{
get
;
}
=
new
AsyncEvent
<
MqttClientConnectedEventArgs
>();
public
AsyncEvent
<
MqttClientConnectingEventArgs
>
ConnectingEvent
{
get
;
}
=
new
AsyncEvent
<
MqttClientConnectingEventArgs
>();
public
AsyncEvent
<
MqttClientDisconnectedEventArgs
>
DisconnectedEvent
{
get
;
}
=
new
AsyncEvent
<
MqttClientDisconnectedEventArgs
>();
public
AsyncEvent
<
InspectMqttPacketEventArgs
>
InspectPacketEvent
{
get
;
}
=
new
AsyncEvent
<
InspectMqttPacketEventArgs
>();
}
}
\ No newline at end of file
Source/MQTTnet/Client/Internal/MqttClientResultFactory.cs
0 → 100644
浏览文件 @
449624fd
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace
MQTTnet.Client.Internal
{
public
static
class
MqttClientResultFactory
{
public
static
readonly
MqttClientPublishResultFactory
PublishResult
=
new
MqttClientPublishResultFactory
();
public
static
readonly
MqttClientSubscribeResultFactory
SubscribeResult
=
new
MqttClientSubscribeResultFactory
();
public
static
readonly
MqttClientUnsubscribeResultFactory
UnsubscribeResult
=
new
MqttClientUnsubscribeResultFactory
();
}
}
\ No newline at end of file
Source/MQTTnet/Client/MqttClient.cs
浏览文件 @
449624fd
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录