Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
MQTTnet
提交
99f4f460
MQTTnet
项目概览
dotNET Platform
/
MQTTnet
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
99f4f460
编写于
5月 04, 2023
作者:
C
Christian
提交者:
GitHub
5月 04, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new overloads for packet payload and will payload (#1721)
上级
b08d11c0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
24 deletion
+37
-24
.github/workflows/ReleaseNotes.md
.github/workflows/ReleaseNotes.md
+1
-0
Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs
Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs
+13
-1
Source/MQTTnet/Client/Publishing/MqttClientPublishResult.cs
Source/MQTTnet/Client/Publishing/MqttClientPublishResult.cs
+1
-1
Source/MQTTnet/MqttApplicationMessageBuilder.cs
Source/MQTTnet/MqttApplicationMessageBuilder.cs
+22
-22
未找到文件。
.github/workflows/ReleaseNotes.md
浏览文件 @
99f4f460
*
[Core] Add validation of maximum string lengths (#1718).
*
[Client] Added overloads for setting packet payload and will payload (#1720).
*
[Server] Improved performance by changing internal locking strategy for subscriptions (#1716, thanks to @zeheng).
Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs
浏览文件 @
99f4f460
// Licensed to the .NET Foundation under one or more agreements.
// 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.
...
...
@@ -421,6 +421,18 @@ namespace MQTTnet.Client
return
this
;
}
public
MqttClientOptionsBuilder
WithWillPayload
(
ArraySegment
<
byte
>
willPayload
)
{
if
(
willPayload
.
Count
==
0
)
{
_options
.
WillPayload
=
null
;
return
this
;
}
_options
.
WillPayload
=
willPayload
.
ToArray
();
return
this
;
}
public
MqttClientOptionsBuilder
WithWillPayload
(
string
willPayload
)
{
if
(
string
.
IsNullOrEmpty
(
willPayload
))
...
...
Source/MQTTnet/Client/Publishing/MqttClientPublishResult.cs
浏览文件 @
99f4f460
...
...
@@ -34,7 +34,7 @@ namespace MQTTnet.Client
/// Gets or sets the reason code.
/// <remarks>MQTT 5.0.0+ feature.</remarks>
/// </summary>
public
MqttClientPublishReasonCode
ReasonCode
{
get
;
}
=
MqttClientPublishReasonCode
.
Success
;
public
MqttClientPublishReasonCode
ReasonCode
{
get
;
}
/// <summary>
/// Gets or sets the reason string.
...
...
Source/MQTTnet/MqttApplicationMessageBuilder.cs
浏览文件 @
99f4f460
...
...
@@ -2,16 +2,16 @@
// 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.Exceptions
;
using
MQTTnet.Internal
;
using
MQTTnet.Packets
;
using
MQTTnet.Protocol
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
MQTTnet.Exceptions
;
using
MQTTnet.Internal
;
using
MQTTnet.Packets
;
using
MQTTnet.Protocol
;
namespace
MQTTnet
{
...
...
@@ -20,9 +20,9 @@ namespace MQTTnet
string
_contentType
;
byte
[]
_correlationData
;
uint
_messageExpiryInterval
;
ArraySegment
<
byte
>
_payloadSegment
;
MqttPayloadFormatIndicator
_payloadFormatIndicator
;
ArraySegment
<
byte
>
_payloadSegment
;
MqttQualityOfServiceLevel
_qualityOfServiceLevel
=
MqttQualityOfServiceLevel
.
AtMostOnce
;
string
_responseTopic
;
bool
_retain
;
...
...
@@ -89,13 +89,11 @@ namespace MQTTnet
public
MqttApplicationMessageBuilder
WithPayload
(
byte
[]
payload
)
{
_payloadSegment
=
payload
==
null
||
payload
.
Length
==
0
?
EmptyBuffer
.
ArraySegment
:
new
ArraySegment
<
byte
>(
payload
);
_payloadSegment
=
payload
==
null
||
payload
.
Length
==
0
?
EmptyBuffer
.
ArraySegment
:
new
ArraySegment
<
byte
>(
payload
);
return
this
;
}
public
MqttApplicationMessageBuilder
WithPayload
Segment
(
ArraySegment
<
byte
>
payloadSegment
)
public
MqttApplicationMessageBuilder
WithPayload
(
ArraySegment
<
byte
>
payloadSegment
)
{
_payloadSegment
=
payloadSegment
;
return
this
;
...
...
@@ -123,9 +121,7 @@ namespace MQTTnet
public
MqttApplicationMessageBuilder
WithPayload
(
Stream
payload
)
{
return
payload
==
null
?
WithPayload
(
default
(
byte
[]))
:
WithPayload
(
payload
,
payload
.
Length
-
payload
.
Position
);
return
payload
==
null
?
WithPayload
(
default
(
byte
[]))
:
WithPayload
(
payload
,
payload
.
Length
-
payload
.
Position
);
}
public
MqttApplicationMessageBuilder
WithPayload
(
Stream
payload
,
long
length
)
...
...
@@ -162,16 +158,6 @@ namespace MQTTnet
return
WithPayload
(
payloadBuffer
);
}
#if NETCOREAPP3_1_OR_GREATER || NETSTANDARD2_1
public
MqttApplicationMessageBuilder
WithPayloadSegment
(
ReadOnlyMemory
<
byte
>
payloadSegment
)
{
return
MemoryMarshal
.
TryGetArray
(
payloadSegment
,
out
var
segment
)
?
WithPayloadSegment
(
segment
)
:
WithPayload
(
payloadSegment
.
ToArray
());
}
#endif
/// <summary>
/// Adds the payload format indicator to the message.
/// <remarks>MQTT 5.0.0+ feature.</remarks>
...
...
@@ -182,6 +168,20 @@ namespace MQTTnet
return
this
;
}
public
MqttApplicationMessageBuilder
WithPayloadSegment
(
ArraySegment
<
byte
>
payloadSegment
)
{
_payloadSegment
=
payloadSegment
;
return
this
;
}
#if NETCOREAPP3_1_OR_GREATER || NETSTANDARD2_1
public
MqttApplicationMessageBuilder
WithPayloadSegment
(
ReadOnlyMemory
<
byte
>
payloadSegment
)
{
return
MemoryMarshal
.
TryGetArray
(
payloadSegment
,
out
var
segment
)
?
WithPayloadSegment
(
segment
)
:
WithPayload
(
payloadSegment
.
ToArray
());
}
#endif
/// <summary>
/// The quality of service level.
/// The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录