diff --git a/mqtt/hook.go b/mqtt/hook.go index e07f67b..7cf9a48 100644 --- a/mqtt/hook.go +++ b/mqtt/hook.go @@ -55,19 +55,6 @@ func (h *MqttServerHook) subscribeCallback(cl *mqttServerV2.Client, sub packets. func (h *MqttServerHook) OnConnect(cl *mqttServerV2.Client, pk packets.Packet) error { h.Log.Info("client connected", "client", cl.ID) - // session := GetSession(cl.ID) - // if session != nil { - - // } - // Example demonstrating how to subscribe to a topic within the hook. - //h.config.Server.Subscribe("hook/direct/publish", 1, h.subscribeCallback) - - // Example demonstrating how to publish a message within the hook - //err := h.config.Server.Publish("hook/direct/publish", []byte("packet hook message"), false, 0) - //if err != nil { - // h.Log.Error("hook.publish", "error", err) - //} - return nil } @@ -78,6 +65,9 @@ func (h *MqttServerHook) OnDisconnect(cl *mqttServerV2.Client, err error, expire h.Log.Info("client disconnected", "client", cl.ID, "expire", expire) } + session := GetSession(cl.ID) + MqttClientDisconnect(session) + } func (h *MqttServerHook) OnSubscribed(cl *mqttServerV2.Client, pk packets.Packet, reasonCodes []byte) {