package packets import ( "badat.dev/maeqtt/v2/mqtt/properties" "io" ) type PubackReasonCode byte const ( PubackReasonCodeSuccess PubackReasonCode = 0 PubackReasonCodeNoMatchingSubscribers PubackReasonCode = 16 PubackReasonCodeUnspecifiedError PubackReasonCode = 128 PubackReasonCodeImplementationSpecyficEror PubackReasonCode = 131 PubackReasonCodeNotAuthorized PubackReasonCode = 135 PubackReasonCodeTopicNameInvalid PubackReasonCode = 144 PubackReasonCodePacketIDInUse PubackReasonCode = 145 PubackReasonCodeQuotaExceeded PubackReasonCode = 151 PubackReasonCodePayloadFormatInvalid PubackReasonCode = 153 ) type PubackPacket struct { PacketID uint16 Properties properties.PubackPacketProperties Reason PubackReasonCode } func (p PubackPacket) Write(w io.Writer) error { resp := pubRespPacket{ PacketType: PacketTypePuback, PacketID: p.PacketID, Properties: p.Properties.ArrayOf(), Reason: byte(p.Reason), } return resp.Write(w) } type PubrecPacket struct { PacketID uint16 Properties properties.PubrecPacketProperties Reason PubackReasonCode } func (p PubrecPacket) Write(w io.Writer) error { resp := pubRespPacket{ PacketType: PacketTypePubrec, PacketID: p.PacketID, Properties: p.Properties.ArrayOf(), Reason: byte(p.Reason), } return resp.Write(w) } type PubrelReasonCode byte const ( PubrelReasonCodeSuccess PubackReasonCode = 0 PubrelReasonPacketIDNotFound PubackReasonCode = 146 ) type PubrelPacket struct { PacketID uint16 Properties properties.PubrecPacketProperties Reason PubrelReasonCode } func (p PubrelPacket) Write(w io.Writer) error { resp := pubRespPacket{ PacketType: PacketTypePubrel, PacketID: p.PacketID, Properties: p.Properties.ArrayOf(), Reason: byte(p.Reason), } return resp.Write(w) } type PubcompPacket struct { PacketID uint16 Properties properties.PubcompPacketProperties Reason PubrelReasonCode } func (p PubcompPacket) Write(w io.Writer) error { resp := pubRespPacket{ PacketType: PacketTypePubrel, PacketID: p.PacketID, Properties: p.Properties.ArrayOf(), Reason: byte(p.Reason), } return resp.Write(w) }