Skip to content

Commit ca34b93

Browse files
jmacwhytedeadprogram
authored andcommitted
add last-will-and-testament to MQTT
1 parent 2cfc08b commit ca34b93

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/mqtt/mqtt.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ func (c *mqttclient) Connect() Token {
100100
connectPkt.ProtocolName = "MQTT"
101101
connectPkt.Keepalive = 60
102102

103+
connectPkt.WillFlag = c.opts.WillEnabled
104+
connectPkt.WillTopic = c.opts.WillTopic
105+
connectPkt.WillMessage = c.opts.WillPayload
106+
connectPkt.WillQos = c.opts.WillQos
107+
connectPkt.WillRetain = c.opts.WillRetained
108+
103109
err = connectPkt.Write(c.conn)
104110
if err != nil {
105111
return &mqtttoken{err: err}

0 commit comments

Comments
 (0)