Skip to content

Commit 7d343da

Browse files
committed
Add pingreq handler when active, not when handler is added
1 parent 49c60c4 commit 7d343da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/MQTTNIO/ChannelHandlers/MQTTMessageHandler.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ class MQTTMessageHandler: ChannelDuplexHandler {
3535
}
3636

3737
func handlerAdded(context: ChannelHandlerContext) {
38+
if context.channel.isActive {
39+
self.pingreqHandler?.start(context: context)
40+
}
41+
}
42+
43+
func channelActive(context: ChannelHandlerContext) {
3844
self.pingreqHandler?.start(context: context)
3945
}
4046

41-
func handlerRemoved(context: ChannelHandlerContext) {
47+
func channelInactive(context: ChannelHandlerContext) {
4248
self.pingreqHandler?.stop()
4349
}
4450

0 commit comments

Comments
 (0)