MqttHelperSendMqttStreamAsync 方法 |
使用MQTT协议将流中的数据读取到字节数组,然后都写入到socket里面,可以指定进度报告,主要用于将文件发送到网络。
Use the MQTT protocol to read the data in the stream into a byte array, and then write them all into the socket.
You can specify a progress report, which is mainly used to send files to the network.
命名空间:
HslCommunication.MQTT
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 public static Task<OperateResult> SendMqttStreamAsync(
CommunicationPipe pipe,
Stream stream,
long fileSize,
int timeOut,
Action<long, long> reportProgress = null,
AesCryptography aesCryptography = null,
HslCancelToken cancelToken = null
)
Public Shared Function SendMqttStreamAsync (
pipe As CommunicationPipe,
stream As Stream,
fileSize As Long,
timeOut As Integer,
Optional reportProgress As Action(Of Long, Long) = Nothing,
Optional aesCryptography As AesCryptography = Nothing,
Optional cancelToken As HslCancelToken = Nothing
) As Task(Of OperateResult)
public:
static Task<OperateResult^>^ SendMqttStreamAsync(
CommunicationPipe^ pipe,
Stream^ stream,
long long fileSize,
int timeOut,
Action<long long, long long>^ reportProgress = nullptr,
AesCryptography^ aesCryptography = nullptr,
HslCancelToken^ cancelToken = nullptr
)
static member SendMqttStreamAsync :
pipe : CommunicationPipe *
stream : Stream *
fileSize : int64 *
timeOut : int *
?reportProgress : Action<int64, int64> *
?aesCryptography : AesCryptography *
?cancelToken : HslCancelToken
(* Defaults:
let _reportProgress = defaultArg reportProgress null
let _aesCryptography = defaultArg aesCryptography null
let _cancelToken = defaultArg cancelToken null
*)
-> Task<OperateResult>
参数
- pipe
- 类型:HslCommunication.Core.PipeCommunicationPipe
当前的管道对象信息 - stream
- 类型:System.IOStream
流 - fileSize
- 类型:SystemInt64
总的数据大小 - timeOut
- 类型:SystemInt32
超时信息 - reportProgress (Optional)
- 类型:SystemActionInt64, Int64
进度报告,第一个参数是已完成的字节数量,第二个参数是总字节数量。 - aesCryptography (Optional)
- 类型:HslCommunication.Core.SecurityAesCryptography
AES数据加密对象,如果为空,则不进行加密 - cancelToken (Optional)
- 类型:HslCommunication.CoreHslCancelToken
取消操作的令牌信息
返回值
类型:
TaskOperateResult是否操作成功
参见