10
10
import com .jun .mqttx .utils .TopicUtils ;
11
11
import io .netty .buffer .ByteBuf ;
12
12
import io .netty .buffer .Unpooled ;
13
- import io .netty .channel .Channel ;
14
13
import io .netty .channel .ChannelHandlerContext ;
15
14
import io .netty .channel .group .ChannelGroup ;
16
15
import io .netty .channel .group .DefaultChannelGroup ;
17
16
import io .netty .handler .codec .mqtt .*;
18
- import io .netty .util .AttributeKey ;
19
17
import io .netty .util .concurrent .GlobalEventExecutor ;
20
18
21
19
import java .util .ArrayList ;
34
32
@ Handler (type = MqttMessageType .SUBSCRIBE )
35
33
public class SubscribeHandler extends AbstractMqttTopicSecureHandler {
36
34
//@formatter:off
37
- /** 客户端订阅的系统主题 key, 用于 {@link Channel#attr( AttributeKey)} */
38
- public static final String SYS_TOPICS_ATTR = "sys_topics" ;
39
-
40
35
private final boolean enableTopicPubSubSecure ;
41
36
private IRetainMessageService retainMessageService ;
42
37
private ISubscriptionService subscriptionService ;
@@ -46,9 +41,13 @@ public class SubscribeHandler extends AbstractMqttTopicSecureHandler {
46
41
private MqttQoS sysTopicQos ;
47
42
private String version ;
48
43
49
- /** 系统主题 $SYS 订阅群组 */
50
- public static final ChannelGroup sysChannels = new DefaultChannelGroup (GlobalEventExecutor .INSTANCE );
51
- /** 定时任务执行器 */
44
+ /**
45
+ * 系统主题 $SYS 订阅群组
46
+ */
47
+ public static ChannelGroup sysChannels ;
48
+ /**
49
+ * 定时任务执行器
50
+ */
52
51
private ScheduledExecutorService fixRateExecutor ;
53
52
/** 系统主题消息 id */
54
53
private AtomicInteger sysTopicMsgId ;
@@ -64,6 +63,7 @@ public SubscribeHandler(IRetainMessageService retainMessageService, ISubscriptio
64
63
this .version = mqttxConfig .getVersion ();
65
64
this .enableSysTopic = mqttxConfig .getSysTopic ().getEnable ();
66
65
if (enableSysTopic ) {
66
+ SubscribeHandler .sysChannels = new DefaultChannelGroup (GlobalEventExecutor .INSTANCE );
67
67
this .interval = mqttxConfig .getSysTopic ().getInterval ().getSeconds ();
68
68
this .sysTopicQos = MqttQoS .valueOf (mqttxConfig .getSysTopic ().getQos ());
69
69
fixRateExecutor = Executors .newSingleThreadScheduledExecutor ();
0 commit comments