提交 7d5a27e2 编写于 作者: 浅梦2013's avatar 浅梦2013

代码优化。

上级 0f99cbe4
......@@ -32,14 +32,10 @@ import java.io.Serializable;
@AllArgsConstructor
public class MqttDisconnectEvent implements Serializable {
/**
* 异常信息
*/
Throwable throwable;
/**
* 断开原因
*/
String remark;
String reason;
/**
* 是否删除连接
*/
......
......@@ -44,12 +44,15 @@ public class SpringEventMqttClientConnectListener implements IMqttClientConnectL
@Override
public void onDisconnect(ChannelContext channelContext, Throwable throwable, String remark, boolean isRemove) {
String reason;
if (throwable == null) {
reason = remark;
log.info("mqtt 链接断开 remark:{} isRemove:{}", remark, isRemove);
} else {
reason = remark + " Exception:" + throwable.getMessage();
log.error("mqtt 链接断开 remark:{} isRemove:{}", remark, isRemove, throwable);
}
eventPublisher.publishEvent(new MqttDisconnectEvent(throwable, remark, isRemove));
eventPublisher.publishEvent(new MqttDisconnectEvent(reason, isRemove));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册