add MqttClientDisconnect
This commit is contained in:
parent
f2b81d358b
commit
f3310713fc
16
mqtt/hook.go
16
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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user