VolantMQ / volantmq

High-Performance MQTT Server
Apache License 2.0
982 stars 169 forks source link

what need to do with the "retained" variable? #132

Closed chenyf closed 5 years ago

chenyf commented 5 years ago

Hi, the code in clients/session.go show as below, you create a "retained" variable, set the QoS and topic, but I think you need do something more with this "retained" variable, am I right?

func (s session) SignalPublish(pkt mqttp.Publish) error { // [MQTT-3.3.1.3] if pkt.Retain() { if err := s.messenger.Retain(pkt); err != nil { s.log.Error("Error retaining message", zap.String("clientId", s.id), zap.Error(err)) }

    // [MQTT-3.3.1-7]
    if pkt.QoS() == mqttp.QoS0 {
        retained := mqttp.NewPublish(s.version)
        if err := retained.SetQoS(pkt.QoS()); err != nil {
            s.log.Error("set retained QoS", zap.String("clientId", s.id), zap.Error(err))
        }   
        if err := retained.SetTopic(pkt.Topic()); err != nil {
            s.log.Error("set retained topic", zap.String("clientId", s.id), zap.Error(err))
        }   
    }   
}  
....

}

troian commented 5 years ago

Looks like a dead code