disconnect.go 1005 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package packets
  2. import (
  3. "fmt"
  4. "github.com/pborman/uuid"
  5. "io"
  6. )
  7. //DisconnectPacket is an internal representation of the fields of the
  8. //Disconnect MQTT packet
  9. type DisconnectPacket struct {
  10. FixedHeader
  11. uuid uuid.UUID
  12. }
  13. func (d *DisconnectPacket) String() string {
  14. str := fmt.Sprintf("%s\n", d.FixedHeader)
  15. return str
  16. }
  17. func (d *DisconnectPacket) Write(w io.Writer) error {
  18. packet := d.FixedHeader.pack()
  19. _, err := packet.WriteTo(w)
  20. return err
  21. }
  22. //Unpack decodes the details of a ControlPacket after the fixed
  23. //header has been read
  24. func (d *DisconnectPacket) Unpack(b io.Reader) {
  25. }
  26. //Details returns a Details struct containing the Qos and
  27. //MessageID of this ControlPacket
  28. func (d *DisconnectPacket) Details() Details {
  29. return Details{Qos: 0, MessageID: 0}
  30. }
  31. //UUID returns the unique ID assigned to the ControlPacket when
  32. //it was originally received. Note: this is not related to the
  33. //MessageID field for MQTT packets
  34. func (d *DisconnectPacket) UUID() uuid.UUID {
  35. return d.uuid
  36. }