代码整理

This commit is contained in:
2024-08-21 17:14:00 +08:00
parent e9bc1f37cc
commit 3a378cd7d2
8 changed files with 162 additions and 107 deletions

View File

@@ -39,9 +39,11 @@ const (
)
var (
// ErrNoValidPacketAvailable 表示MQTT规范中不存在提供的数据包类型字节
// ErrNoValidPacketAvailable indicates the packet type byte provided does not exist in the mqtt specification.
ErrNoValidPacketAvailable = errors.New("no valid packet available")
ErrNoValidPacketAvailable = errors.New("没有可用的有效数据包")
// PacketNames 数据包字节到人类可读名称的映射,以便于调试
// PacketNames is a map of packet bytes to human-readable names, for easier debugging.
PacketNames = map[byte]string{
0: "Reserved",
@@ -61,6 +63,25 @@ var (
14: "Disconnect",
15: "Auth",
}
ZHPacketNames = map[string]string{
"Reserved": "Reserved保留字段",
"Connect": "请求连接",
"Connack": "确认连接请求",
"Publish": "发布",
"Puback": "发布确认",
"Pubrec": "发布接收",
"Pubrel": "发布释放",
"Pubcomp": "发布完成",
"Subscribe": "订阅",
"Unsubscribe": "取消订阅",
"Suback": "订阅确认",
"Unsuback": "取消订阅确认",
"Pingreq": "心跳请求",
"Pingresp": "心跳响应",
"Disconnect": "断开连接",
"Auth": "认证",
}
)
// Packets is a concurrency safe map of packets.