docs 补充项目注释
This commit is contained in:
+20
-1
@@ -12,19 +12,38 @@ import org.tio.core.ChannelContext;
|
||||
*/
|
||||
@Slf4j
|
||||
public class MqttClientConnectListener implements IMqttClientConnectListener {
|
||||
//
|
||||
|
||||
private final MqttClientCreator mqttClientCreator;
|
||||
|
||||
/**
|
||||
* 创建 MQTT 客户端连接监听器。
|
||||
*
|
||||
* @param mqttClientCreator MQTT 客户端创建器
|
||||
*/
|
||||
public MqttClientConnectListener(MqttClientCreator mqttClientCreator) {
|
||||
this.mqttClientCreator = mqttClientCreator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户端连接成功回调。
|
||||
*
|
||||
* @param context 通道上下文
|
||||
* @param isReconnect 是否重连
|
||||
*/
|
||||
@Override
|
||||
public void onConnected(ChannelContext context, boolean isReconnect) {
|
||||
// 创建连接
|
||||
log.info("MqttConnectedEvent:{}", context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户端断开连接回调。
|
||||
*
|
||||
* @param context 通道上下文
|
||||
* @param throwable 断开异常
|
||||
* @param remark 断开说明
|
||||
* @param isRemove 是否移除连接
|
||||
*/
|
||||
@Override
|
||||
public void onDisconnect(ChannelContext context, Throwable throwable, String remark, boolean isRemove) {
|
||||
// 离线时更新重连
|
||||
|
||||
+8
@@ -15,6 +15,14 @@ import java.nio.charset.StandardCharsets;
|
||||
@Slf4j
|
||||
public class MqttClientGlobalMessageListener implements IMqttClientGlobalMessageListener {
|
||||
|
||||
/**
|
||||
* 接收并记录全局 MQTT 消息。
|
||||
*
|
||||
* @param context 通道上下文
|
||||
* @param topic 主题
|
||||
* @param message MQTT 消息对象
|
||||
* @param payload 消息载荷
|
||||
*/
|
||||
@Override
|
||||
public void onMessage(ChannelContext context, String topic, MqttPublishMessage message, byte[] payload) {
|
||||
log.info("MqttGlobalMessageEvent => topic: {}, msg: {}", topic, new String(payload, StandardCharsets.UTF_8));
|
||||
|
||||
Reference in New Issue
Block a user