mirror of
https://github.com/fhmq/hmq.git
synced 2026-04-24 10:38:34 +00:00
close
This commit is contained in:
@@ -392,3 +392,17 @@ func (b *Broker) ProcessPublishMessage(packet *packets.PublishPacket) {
|
||||
// s.qmu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Broker) BroadcastUnSubscribe(subs map[string]*subscription) {
|
||||
|
||||
ubsub := packets.NewControlPacket(packets.Unsubscribe).(*packets.UnsubscribePacket)
|
||||
for topic, _ := range subs {
|
||||
// topic := sub.topic
|
||||
// if sub.queue {
|
||||
// topic = "$queue/" + sub.topic
|
||||
// }
|
||||
ubsub.Topics = append(ubsub.Topics, topic)
|
||||
}
|
||||
b.BroadcastSubOrUnsubMessage(ubsub)
|
||||
|
||||
}
|
||||
|
||||
@@ -429,6 +429,9 @@ func (c *client) Close() {
|
||||
log.Error("closed client but remove sublist error, ", err)
|
||||
}
|
||||
}
|
||||
if c.typ == CLIENT {
|
||||
b.BroadcastUnSubscribe(subs)
|
||||
}
|
||||
if c.info.willMsg != nil {
|
||||
b.ProcessPublishMessage(c.info.willMsg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user