com.feingto.iot.server.handler.mqtt.UnSubscribeHandler Maven / Gradle / Ivy
package com.feingto.iot.server.handler.mqtt;
import com.feingto.iot.common.Constants;
import com.feingto.iot.common.service.mqtt.MessageResponse;
import com.feingto.iot.server.cache.SubscribeCache;
import com.feingto.iot.server.handler.BaseMessageHandler;
import io.netty.channel.Channel;
import io.netty.handler.codec.mqtt.MqttMessageType;
import io.netty.handler.codec.mqtt.MqttUnsubscribeMessage;
/**
* Mqtt 消息取消订阅处理器
*
* @author longfei
*/
public class UnSubscribeHandler extends BaseMessageHandler {
public UnSubscribeHandler() {
super(MqttMessageType.UNSUBSCRIBE);
}
@Override
public void handle(Channel channel, Object object) {
MqttUnsubscribeMessage msg = (MqttUnsubscribeMessage) object;
msg.payload().topics().forEach(topic ->
SubscribeCache.getInstance(igniteSubscribe)
.remove(topic, channel.attr(Constants.KEY_CLIENT_ID).get()));
// 返回unsuback消息
MessageResponse.unsuback(channel, msg.variableHeader().messageId());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy