package packets import ( "io" "badat.dev/maeqtt/v2/mqtt/properties" ) type PubackReasonCode byte const ( PubackReasonCodeSuccess PubackReasonCode = 0 PubackReasonCodeNoMatchingSubscribers = 16 PubackReasonCodeUnspecifiedError = 128 PubackReasonCodeImplementationSpecyficEror = 131 PubackReasonCodeNotAuthorized = 135 PubackReasonCodeTopicNameInvalid = 144 PubackReasonCodePacketIDInUse = 145 PubackReasonCodeQuotaExceeded = 151 PubackReasonCodePayloadFormatInvalid = 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 = 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) }