public class MqttHelper extends Object
| 构造器和说明 |
|---|
MqttHelper() |
| 限定符和类型 | 方法和说明 |
|---|---|
static OperateResultExOne<byte[]> |
BuildConnectMqttCommand(MqttConnectionOptions connectionOptions,
String protocol)
创建MQTT连接服务器的报文信息
Create MQTT connection server message information |
static OperateResultExOne<byte[]> |
BuildConnectMqttCommand(MqttConnectionOptions connectionOptions,
String protocol,
RSACryptoServiceProvider rsa)
创建MQTT连接服务器的报文信息
Create MQTT connection server message information |
static byte[] |
BuildIntBytes(int data)
从MQTT的缓存信息里,提取长度信息
Extract length information from MQTT cache information |
static OperateResultExOne<byte[]> |
BuildMqttCommand(byte head,
byte[] variableHeader,
byte[] payLoad,
AesCryptography aesCryptography)
将一个数据打包成一个mqtt协议的内容
Pack a piece of data into a mqtt protocol |
static OperateResultExOne<byte[]> |
BuildMqttCommand(byte control,
byte flags,
byte[] variableHeader,
byte[] payLoad)
将一个数据打包成一个mqtt协议的内容
Pack a piece of data into a mqtt protocol |
static OperateResultExOne<byte[]> |
BuildMqttCommand(byte control,
byte flags,
byte[] variableHeader,
byte[] payLoad,
AesCryptography aesCryptography)
将一个数据打包成一个mqtt协议的内容
Pack a piece of data into a mqtt protocol |
static OperateResultExOne<byte[]> |
BuildPublishMqttCommand(MqttPublishMessage message)
创建Mqtt发送消息的命令
Create Mqtt command to send messages |
static OperateResultExOne<byte[]> |
BuildPublishMqttCommand(String topic,
byte[] payload)
创建Mqtt发送消息的命令
Create Mqtt command to send messages |
static byte[] |
BuildSegCommandByString(String message)
将字符串打包成utf8编码,并且带有2个字节的表示长度的信息
Pack the string into utf8 encoding, and with 2 bytes of length information |
static OperateResultExOne<byte[]> |
BuildSubscribeMqttCommand(MqttSubscribeMessage message)
创建MQTT订阅消息的命名
Command to create Mqtt subscription message |
static OperateResultExOne<byte[]> |
BuildUnSubscribeMqttCommand(MqttSubscribeMessage message)
创建Mqtt取消订阅消息的命令
Create Mqtt unsubscribe message command |
static OperateResultExOne<byte[]> |
CalculateLengthToMqttLength(int length)
根据数据的总长度,计算出剩余的数据长度信息
According to the total length of the data, calculate the remaining data length information |
static OperateResult |
CheckConnectBack(byte code,
byte[] data)
根据服务器返回的信息判断当前的连接是否是可用的
According to the information returned by the server to determine whether the current connection is available |
static OperateResultExTwo<Integer,Integer> |
ExtraIntFromBytes(byte[] buffer,
int index)
从MQTT的缓存信息里,提取长度信息
Extract length information from MQTT cache information |
static OperateResultExTwo<String,byte[]> |
ExtraMqttReceiveData(byte mqttCode,
byte[] data)
解析从MQTT接受的客户端信息,解析成实际的Topic数据及Payload数据
Parse the client information received from MQTT and parse it into actual Topic data and Payload data |
static OperateResultExTwo<String,byte[]> |
ExtraMqttReceiveData(byte mqttCode,
byte[] data,
AesCryptography aesCryptography)
解析从MQTT接受的客户端信息,解析成实际的Topic数据及Payload数据
Parse the client information received from MQTT and parse it into actual Topic data and Payload data |
static OperateResultExTwo<String,Integer> |
ExtraMsgFromBytes(byte[] buffer,
int index)
从MQTT的缓存信息里,提取文本信息
Extract text information from MQTT cache information |
static String |
GetMqttCodeText(int status)
获取当前的错误的描述信息
Get a description of the current error |
public static OperateResultExOne<byte[]> CalculateLengthToMqttLength(int length)
length - 数据的总长度public static OperateResultExOne<byte[]> BuildMqttCommand(byte control, byte flags, byte[] variableHeader, byte[] payLoad)
control - 控制码flags - 标记variableHeader - 可变头的字节内容payLoad - 负载数据public static OperateResultExOne<byte[]> BuildMqttCommand(byte control, byte flags, byte[] variableHeader, byte[] payLoad, AesCryptography aesCryptography)
control - 控制码flags - 标记variableHeader - 可变头的字节内容payLoad - 负载数据aesCryptography - AES的加密解密对象public static OperateResultExOne<byte[]> BuildMqttCommand(byte head, byte[] variableHeader, byte[] payLoad, AesCryptography aesCryptography)
head - 控制码variableHeader - 可变头的字节内容payLoad - 负载数据aesCryptography - AES加密对象public static byte[] BuildSegCommandByString(String message)
message - 文本消息public static OperateResultExTwo<String,Integer> ExtraMsgFromBytes(byte[] buffer, int index)
buffer - Mqtt的报文index - 索引public static OperateResultExTwo<Integer,Integer> ExtraIntFromBytes(byte[] buffer, int index)
buffer - Mqtt的报文index - 索引public static byte[] BuildIntBytes(int data)
data - 数据信息public static OperateResultExOne<byte[]> BuildConnectMqttCommand(MqttConnectionOptions connectionOptions, String protocol)
connectionOptions - 连接配置protocol - 协议的内容public static OperateResultExOne<byte[]> BuildConnectMqttCommand(MqttConnectionOptions connectionOptions, String protocol, RSACryptoServiceProvider rsa)
connectionOptions - 连接配置protocol - 协议的内容rsa - rsa加密对象public static OperateResult CheckConnectBack(byte code, byte[] data)
code - 功能码data - 数据内容public static String GetMqttCodeText(int status)
status - 状态信息public static OperateResultExOne<byte[]> BuildPublishMqttCommand(MqttPublishMessage message)
message - 封装后的消息内容public static OperateResultExOne<byte[]> BuildPublishMqttCommand(String topic, byte[] payload)
topic - 主题消息内容payload - 数据负载public static OperateResultExOne<byte[]> BuildSubscribeMqttCommand(MqttSubscribeMessage message)
message - 订阅的主题public static OperateResultExOne<byte[]> BuildUnSubscribeMqttCommand(MqttSubscribeMessage message)
message - 订阅的主题public static OperateResultExTwo<String,byte[]> ExtraMqttReceiveData(byte mqttCode, byte[] data)
mqttCode - MQTT的命令码data - 接收的MQTT原始的消息内容public static OperateResultExTwo<String,byte[]> ExtraMqttReceiveData(byte mqttCode, byte[] data, AesCryptography aesCryptography)
mqttCode - MQTT的命令码data - 接收的MQTT原始的消息内容aesCryptography - AES加密解密的对象Copyright © 2022. All rights reserved.