点击或拖拽改变大小

MqttSyncClientRead 方法

从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 中) 版本:11.8.2.0 (11.8.2.0)
语法
public OperateResult<string, byte[]> Read(
	string topic,
	byte[] payload,
	Action<long, long> sendProgress = null,
	Action<string, string> handleProgress = null,
	Action<long, long> receiveProgress = null
)

参数

topic
类型:SystemString
主题信息
payload
类型:SystemByte
负载数据
sendProgress (Optional)
类型:SystemActionInt64, Int64
发送数据给服务器时的进度报告,第一个参数为已发送数据,第二个参数为总发送数据
handleProgress (Optional)
类型:SystemActionString, String
服务器处理数据的进度报告,第一个参数Topic自定义,通常用来传送操作百分比,第二个参数自定义,通常用来表示服务器消息
receiveProgress (Optional)
类型:SystemActionInt64, Int64
从服务器接收数据的进度报告,第一个参数为已接收数据,第二个参数为总接收数据

返回值

类型:OperateResultString, Byte
服务器返回的数据信息
备注
进度报告可以实现一个比较有意思的功能,可以用来数据的上传和下载,提供一个友好的进度条,因为网络的好坏通常是不确定的。
参见