MqttSyncClientReadAsync 方法 |
从MQTT服务器同步读取数据,将payload发送到服务器,然后从服务器返回相关的数据,支持数据发送进度报告,服务器执行进度报告,接收数据进度报告操作
Synchronously read data from the MQTT server, send the payload to the server, and then return relevant data from the server,
support data transmission progress report, the server executes the progress report, and receives the data progress report
命名空间:
HslCommunication.MQTT
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 public Task<OperateResult<string, byte[]>> ReadAsync(
string topic,
byte[] payload,
Action<long, long> sendProgress = null,
Action<string, string> handleProgress = null,
Action<long, long> receiveProgress = null
)
Public Function ReadAsync (
topic As String,
payload As Byte(),
Optional sendProgress As Action(Of Long, Long) = Nothing,
Optional handleProgress As Action(Of String, String) = Nothing,
Optional receiveProgress As Action(Of Long, Long) = Nothing
) As Task(Of OperateResult(Of String, Byte()))
public:
Task<OperateResult<String^, array<unsigned char>^>^>^ ReadAsync(
String^ topic,
array<unsigned char>^ payload,
Action<long long, long long>^ sendProgress = nullptr,
Action<String^, String^>^ handleProgress = nullptr,
Action<long long, long long>^ receiveProgress = nullptr
)
member ReadAsync :
topic : string *
payload : byte[] *
?sendProgress : Action<int64, int64> *
?handleProgress : Action<string, string> *
?receiveProgress : Action<int64, int64>
(* Defaults:
let _sendProgress = defaultArg sendProgress null
let _handleProgress = defaultArg handleProgress null
let _receiveProgress = defaultArg receiveProgress null
*)
-> Task<OperateResult<string, byte[]>>
参数
- topic
- 类型:SystemString
主题信息 - payload
- 类型:SystemByte
负载数据 - sendProgress (Optional)
- 类型:SystemActionInt64, Int64
发送数据给服务器时的进度报告,第一个参数为已发送数据,第二个参数为总发送数据 - handleProgress (Optional)
- 类型:SystemActionString, String
服务器处理数据的进度报告,第一个参数Topic自定义,通常用来传送操作百分比,第二个参数自定义,通常用来表示服务器消息 - receiveProgress (Optional)
- 类型:SystemActionInt64, Int64
从服务器接收数据的进度报告,第一个参数为已接收数据,第二个参数为总接收数据
返回值
类型:
TaskOperateResultString,
Byte服务器返回的数据信息
备注
进度报告可以实现一个比较有意思的功能,可以用来数据的上传和下载,提供一个友好的进度条,因为网络的好坏通常是不确定的。
参见