Commit 14336002f364707c4bc900a75047189dce7fcb85

Authored by YunaiV
1 parent 73e97d16

review:【iot 物联网】mqtt 协议

yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/config/IotGatewayProperties.java
... ... @@ -353,7 +353,6 @@ public class IotGatewayProperties {
353 353 * 连接超时时间(秒)
354 354 */
355 355 private Integer connectTimeoutSeconds = 60;
356   -
357 356 /**
358 357 * 保持连接超时时间(秒)
359 358 */
... ... @@ -363,7 +362,6 @@ public class IotGatewayProperties {
363 362 * 是否启用 SSL
364 363 */
365 364 private Boolean sslEnabled = false;
366   -
367 365 /**
368 366 * SSL 配置
369 367 */
... ... @@ -379,27 +377,22 @@ public class IotGatewayProperties {
379 377 * 密钥证书选项
380 378 */
381 379 private io.vertx.core.net.KeyCertOptions keyCertOptions;
382   -
383 380 /**
384 381 * 信任选项
385 382 */
386 383 private io.vertx.core.net.TrustOptions trustOptions;
387   -
388 384 /**
389 385 * SSL 证书路径
390 386 */
391 387 private String certPath;
392   -
393 388 /**
394 389 * SSL 私钥路径
395 390 */
396 391 private String keyPath;
397   -
398 392 /**
399 393 * 信任存储路径
400 394 */
401 395 private String trustStorePath;
402   -
403 396 /**
404 397 * 信任存储密码
405 398 */
... ...
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/IotMqttUpstreamProtocol.java
... ... @@ -50,6 +50,7 @@ public class IotMqttUpstreamProtocol {
50 50 this.serverId = IotDeviceMessageUtils.generateServerId(mqttProperties.getPort());
51 51 }
52 52  
  53 + // TODO @haohao:这里的编写,是不是和 tcp 对应的,风格保持一致哈;
53 54 @PostConstruct
54 55 public void start() {
55 56 // 创建服务器选项
... ...
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/manager/IotMqttConnectionManager.java
... ... @@ -46,7 +46,9 @@ public class IotMqttConnectionManager {
46 46 }
47 47 } catch (Exception e) {
48 48 // 忽略异常,返回默认值
  49 + // TODO @haohao:这个比较稳定会出现哇?
49 50 }
  51 + // TODO @haohao:这个要枚举下么?
50 52 return "unknown";
51 53 }
52 54  
... ... @@ -194,4 +196,5 @@ public class IotMqttConnectionManager {
194 196 private boolean authenticated;
195 197  
196 198 }
  199 +
197 200 }
... ...
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttDownstreamHandler.java
... ... @@ -69,7 +69,6 @@ public class IotMqttDownstreamHandler {
69 69  
70 70 // 5. 发送消息到设备
71 71 return sendMessageToDevice(message, connectionInfo, payload);
72   -
73 72 } catch (Exception e) {
74 73 if (message != null) {
75 74 log.error("[handleDownstreamMessage][处理下行消息异常,设备 ID:{},错误:{}]",
... ...
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttUpstreamHandler.java
... ... @@ -40,6 +40,7 @@ public class IotMqttUpstreamHandler {
40 40  
41 41 public IotMqttUpstreamHandler(IotMqttUpstreamProtocol protocol,
42 42 IotDeviceMessageService deviceMessageService,
  43 + // TODO @haohao:用不到的 deviceService 可以删除哈;
43 44 IotDeviceService deviceService,
44 45 IotMqttConnectionManager connectionManager) {
45 46 this.deviceMessageService = deviceMessageService;
... ... @@ -70,6 +71,7 @@ public class IotMqttUpstreamHandler {
70 71  
71 72 log.info("[handle][设备认证成功,建立连接,客户端 ID: {},用户名: {}]", clientId, username);
72 73  
  74 + // TODO @haohao:这里是不是少了序号哈?
73 75 // 设置异常和关闭处理器
74 76 endpoint.exceptionHandler(ex -> {
75 77 log.warn("[handle][连接异常,客户端 ID: {},地址: {}]", clientId, getEndpointAddress(endpoint));
... ...