packets

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2024 License: EPL-2.0 Imports: 7 Imported by: 25

Documentation

Index

Constants

View Source
const (
	AuthSuccess                = 0x00
	AuthContinueAuthentication = 0x18
	AuthReauthenticate         = 0x19
)

AuthSuccess is the return code for successful authentication

View Source
const (
	ConnackSuccess                     = 0x00
	ConnackUnspecifiedError            = 0x80
	ConnackMalformedPacket             = 0x81
	ConnackProtocolError               = 0x82
	ConnackImplementationSpecificError = 0x83
	ConnackUnsupportedProtocolVersion  = 0x84
	ConnackInvalidClientID             = 0x85
	ConnackBadUsernameOrPassword       = 0x86
	ConnackNotAuthorized               = 0x87
	ConnackServerUnavailable           = 0x88
	ConnackServerBusy                  = 0x89
	ConnackBanned                      = 0x8A
	ConnackBadAuthenticationMethod     = 0x8C
	ConnackTopicNameInvalid            = 0x90
	ConnackPacketTooLarge              = 0x95
	ConnackQuotaExceeded               = 0x97
	ConnackPayloadFormatInvalid        = 0x99
	ConnackRetainNotSupported          = 0x9A
	ConnackQoSNotSupported             = 0x9B
	ConnackUseAnotherServer            = 0x9C
	ConnackServerMoved                 = 0x9D
	ConnackConnectionRateExceeded      = 0x9F
)
View Source
const (
	DisconnectNormalDisconnection                 = 0x00
	DisconnectDisconnectWithWillMessage           = 0x04
	DisconnectUnspecifiedError                    = 0x80
	DisconnectMalformedPacket                     = 0x81
	DisconnectProtocolError                       = 0x82
	DisconnectImplementationSpecificError         = 0x83
	DisconnectNotAuthorized                       = 0x87
	DisconnectServerBusy                          = 0x89
	DisconnectServerShuttingDown                  = 0x8B
	DisconnectKeepAliveTimeout                    = 0x8D
	DisconnectSessionTakenOver                    = 0x8E
	DisconnectTopicFilterInvalid                  = 0x8F
	DisconnectTopicNameInvalid                    = 0x90
	DisconnectReceiveMaximumExceeded              = 0x93
	DisconnectTopicAliasInvalid                   = 0x94
	DisconnectPacketTooLarge                      = 0x95
	DisconnectMessageRateTooHigh                  = 0x96
	DisconnectQuotaExceeded                       = 0x97
	DisconnectAdministrativeAction                = 0x98
	DisconnectPayloadFormatInvalid                = 0x99
	DisconnectRetainNotSupported                  = 0x9A
	DisconnectQoSNotSupported                     = 0x9B
	DisconnectUseAnotherServer                    = 0x9C
	DisconnectServerMoved                         = 0x9D
	DisconnectSharedSubscriptionNotSupported      = 0x9E
	DisconnectConnectionRateExceeded              = 0x9F
	DisconnectMaximumConnectTime                  = 0xA0
	DisconnectSubscriptionIdentifiersNotSupported = 0xA1
	DisconnectWildcardSubscriptionsNotSupported   = 0xA2
)

DisconnectNormalDisconnection, etc are the list of valid disconnection reason codes.

View Source
const (
	CONNECT byte
	CONNACK
	PUBLISH
	PUBACK
	PUBREC
	PUBREL
	PUBCOMP
	SUBSCRIBE
	SUBACK
	UNSUBSCRIBE
	UNSUBACK
	PINGREQ
	PINGRESP
	DISCONNECT
	AUTH
)

The following consts are the packet type number for each of the different control packets in MQTT

View Source
const (
	PropPayloadFormat          byte = 1
	PropMessageExpiry          byte = 2
	PropContentType            byte = 3
	PropResponseTopic          byte = 8
	PropCorrelationData        byte = 9
	PropSubscriptionIdentifier byte = 11
	PropSessionExpiryInterval  byte = 17
	PropAssignedClientID       byte = 18
	PropServerKeepAlive        byte = 19
	PropAuthMethod             byte = 21
	PropAuthData               byte = 22
	PropRequestProblemInfo     byte = 23
	PropWillDelayInterval      byte = 24
	PropRequestResponseInfo    byte = 25
	PropResponseInfo           byte = 26
	PropServerReference        byte = 28
	PropReasonString           byte = 31
	PropReceiveMaximum         byte = 33
	PropTopicAliasMaximum      byte = 34
	PropTopicAlias             byte = 35
	PropMaximumQOS             byte = 36
	PropRetainAvailable        byte = 37
	PropUser                   byte = 38
	PropMaximumPacketSize      byte = 39
	PropWildcardSubAvailable   byte = 40
	PropSubIDAvailable         byte = 41
	PropSharedSubAvailable     byte = 42
)

PropPayloadFormat, etc are the list of property codes for the MQTT packet properties

View Source
const (
	PubackSuccess                     = 0x00
	PubackNoMatchingSubscribers       = 0x10
	PubackUnspecifiedError            = 0x80
	PubackImplementationSpecificError = 0x83
	PubackNotAuthorized               = 0x87
	PubackTopicNameInvalid            = 0x90
	PubackPacketIdentifierInUse       = 0x91
	PubackQuotaExceeded               = 0x97
	PubackPayloadFormatInvalid        = 0x99
)

PubackSuccess, etc are the list of valid puback reason codes.

View Source
const (
	PubcompSuccess                  = 0x00
	PubcompPacketIdentifierNotFound = 0x92
)

PubcompSuccess, etc are the list of valid pubcomp reason codes.

View Source
const (
	PubrecSuccess                     = 0x00
	PubrecNoMatchingSubscribers       = 0x10
	PubrecUnspecifiedError            = 0x80
	PubrecImplementationSpecificError = 0x83
	PubrecNotAuthorized               = 0x87
	PubrecTopicNameInvalid            = 0x90
	PubrecPacketIdentifierInUse       = 0x91
	PubrecQuotaExceeded               = 0x97
	PubrecPayloadFormatInvalid        = 0x99
)

PubrecSuccess, etc are the list of valid Pubrec reason codes

View Source
const (
	SubackGrantedQoS0                         = 0x00
	SubackGrantedQoS1                         = 0x01
	SubackGrantedQoS2                         = 0x02
	SubackUnspecifiederror                    = 0x80
	SubackImplementationspecificerror         = 0x83
	SubackNotauthorized                       = 0x87
	SubackTopicFilterinvalid                  = 0x8F
	SubackPacketIdentifierinuse               = 0x91
	SubackQuotaexceeded                       = 0x97
	SubackSharedSubscriptionnotsupported      = 0x9E
	SubackSubscriptionIdentifiersnotsupported = 0xA1
	SubackWildcardsubscriptionsnotsupported   = 0xA2
)

SubackGrantedQoS0, etc are the list of valid suback reason codes.

View Source
const (
	UnsubackSuccess                     = 0x00
	UnsubackNoSubscriptionFound         = 0x11
	UnsubackUnspecifiedError            = 0x80
	UnsubackImplementationSpecificError = 0x83
	UnsubackNotAuthorized               = 0x87
	UnsubackTopicFilterInvalid          = 0x8F
	UnsubackPacketIdentifierInUse       = 0x91
)

UnsubackSuccess, etc are the list of valid unsuback reason codes.

Variables

View Source
var ValidProperties = map[byte]map[byte]struct{}{
	PropPayloadFormat:          {CONNECT: {}, PUBLISH: {}},
	PropMessageExpiry:          {CONNECT: {}, PUBLISH: {}},
	PropContentType:            {CONNECT: {}, PUBLISH: {}},
	PropResponseTopic:          {CONNECT: {}, PUBLISH: {}},
	PropCorrelationData:        {CONNECT: {}, PUBLISH: {}},
	PropTopicAlias:             {PUBLISH: {}},
	PropSubscriptionIdentifier: {PUBLISH: {}, SUBSCRIBE: {}},
	PropSessionExpiryInterval:  {CONNECT: {}, CONNACK: {}, DISCONNECT: {}},
	PropAssignedClientID:       {CONNACK: {}},
	PropServerKeepAlive:        {CONNACK: {}},
	PropWildcardSubAvailable:   {CONNACK: {}},
	PropSubIDAvailable:         {CONNACK: {}},
	PropSharedSubAvailable:     {CONNACK: {}},
	PropRetainAvailable:        {CONNACK: {}},
	PropResponseInfo:           {CONNACK: {}},
	PropAuthMethod:             {CONNECT: {}, CONNACK: {}, AUTH: {}},
	PropAuthData:               {CONNECT: {}, CONNACK: {}, AUTH: {}},
	PropRequestProblemInfo:     {CONNECT: {}},
	PropWillDelayInterval:      {CONNECT: {}},
	PropRequestResponseInfo:    {CONNECT: {}},
	PropServerReference:        {CONNACK: {}, DISCONNECT: {}},
	PropReasonString:           {CONNACK: {}, PUBACK: {}, PUBREC: {}, PUBREL: {}, PUBCOMP: {}, SUBACK: {}, UNSUBACK: {}, DISCONNECT: {}, AUTH: {}},
	PropReceiveMaximum:         {CONNECT: {}, CONNACK: {}},
	PropTopicAliasMaximum:      {CONNECT: {}, CONNACK: {}},
	PropMaximumQOS:             {CONNECT: {}, CONNACK: {}},
	PropMaximumPacketSize:      {CONNECT: {}, CONNACK: {}},
	PropUser:                   {CONNECT: {}, CONNACK: {}, PUBLISH: {}, PUBACK: {}, PUBREC: {}, PUBREL: {}, PUBCOMP: {}, SUBSCRIBE: {}, UNSUBSCRIBE: {}, SUBACK: {}, UNSUBACK: {}, DISCONNECT: {}, AUTH: {}},
}

ValidProperties is a map of the various properties and the PacketTypes that property is valid for. A CONNECT packet has own properties, but may also include a separate set of Will Properties. Currently, `CONNECT` covers both sets, this may lead to some invalid properties being accepted (this may be fixed in the future).

Functions

func NewThreadSafeConn added in v0.11.0

func NewThreadSafeConn(c net.Conn) net.Conn

NewThreadSafeConn wraps net.Conn with a mutex. ControlPacket uses it in WriteTo method to ensure parallel writes are thread-Safe.

func ValidateID

func ValidateID(p byte, i byte) bool

ValidateID takes a PacketType and a property name and returns a boolean indicating if that property is valid for that PacketType

Types

type Auth

type Auth struct {
	Properties *Properties
	ReasonCode byte
}

Auth is the Variable Header definition for a Auth control packet

func (*Auth) Buffers

func (a *Auth) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Auth) String added in v0.11.0

func (a *Auth) String() string

func (*Auth) Unpack

func (a *Auth) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Auth) WriteTo

func (a *Auth) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Connack

type Connack struct {
	Properties     *Properties
	ReasonCode     byte
	SessionPresent bool
}

Connack is the Variable Header definition for a connack control packet

func (*Connack) Buffers

func (c *Connack) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Connack) Reason

func (c *Connack) Reason() string

Reason returns a string representation of the meaning of the ReasonCode

func (*Connack) String added in v0.11.0

func (c *Connack) String() string

func (*Connack) Unpack

func (c *Connack) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Connack) WriteTo

func (c *Connack) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Connect

type Connect struct {
	WillMessage     []byte
	Password        []byte
	Username        string
	ProtocolName    string
	ClientID        string
	WillTopic       string
	Properties      *Properties
	WillProperties  *Properties
	KeepAlive       uint16
	ProtocolVersion byte
	WillQOS         byte
	PasswordFlag    bool
	UsernameFlag    bool
	WillRetain      bool
	WillFlag        bool
	CleanStart      bool
}

Connect is the Variable Header definition for a connect control packet

func (*Connect) Buffers

func (c *Connect) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Connect) PackFlags

func (c *Connect) PackFlags() (f byte)

PackFlags takes the Connect flags and packs them into the single byte representation used on the wire by MQTT

func (*Connect) String added in v0.11.0

func (c *Connect) String() string

func (*Connect) Unpack

func (c *Connect) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Connect) UnpackFlags

func (c *Connect) UnpackFlags(b byte)

UnpackFlags takes the wire byte representing the connect options flags and fills out the appropriate variables in the struct

func (*Connect) WriteTo

func (c *Connect) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type ControlPacket

type ControlPacket struct {
	Content Packet
	FixedHeader
}

ControlPacket is the definition of a control packet

func NewControlPacket

func NewControlPacket(t byte) *ControlPacket

NewControlPacket takes a packetType and returns a pointer to a ControlPacket where the VariableHeader field is a pointer to an instance of a VariableHeader definition for that packetType

func ReadPacket

func ReadPacket(r io.Reader) (*ControlPacket, error)

ReadPacket reads a control packet from a io.Reader and returns a completed struct with the appropriate data

func (*ControlPacket) PacketID

func (c *ControlPacket) PacketID() uint16

PacketID is a helper function that returns the value of the PacketID field from any kind of mqtt packet in the Content element

func (*ControlPacket) PacketType added in v0.10.0

func (c *ControlPacket) PacketType() string

PacketType returns the packet type as a string

func (*ControlPacket) String added in v0.12.0

func (c *ControlPacket) String() string

String implements fmt.Stringer (mainly for debugging purposes)

func (*ControlPacket) WriteTo

func (c *ControlPacket) WriteTo(w io.Writer) (int64, error)

WriteTo writes a packet to an io.Writer, handling packing all the parts of a control packet.

type Disconnect

type Disconnect struct {
	Properties *Properties
	ReasonCode byte
}

Disconnect is the Variable Header definition for a Disconnect control packet

func (*Disconnect) Buffers

func (d *Disconnect) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Disconnect) Reason

func (d *Disconnect) Reason() string

Reason returns a string representation of the meaning of the ReasonCode

func (*Disconnect) String added in v0.11.0

func (d *Disconnect) String() string

func (*Disconnect) Unpack

func (d *Disconnect) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Disconnect) WriteTo

func (d *Disconnect) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type FixedHeader

type FixedHeader struct {
	Type  byte
	Flags byte
	// contains filtered or unexported fields
}

FixedHeader is the definition of a control packet fixed header

func (*FixedHeader) WriteTo

func (f *FixedHeader) WriteTo(w io.Writer) (int64, error)

WriteTo operates on a FixedHeader and takes the option values and produces the wire format byte that represents these.

type Packet

type Packet interface {
	Unpack(*bytes.Buffer) error
	Buffers() net.Buffers
	WriteTo(io.Writer) (int64, error)
}

Packet is the interface defining the unique parts of a controlpacket

type Pingreq

type Pingreq struct {
}

Pingreq is the Variable Header definition for a Pingreq control packet

func (*Pingreq) Buffers

func (p *Pingreq) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Pingreq) String added in v0.11.0

func (p *Pingreq) String() string

func (*Pingreq) Unpack

func (p *Pingreq) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Pingreq) WriteTo

func (p *Pingreq) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Pingresp

type Pingresp struct {
}

Pingresp is the Variable Header definition for a Pingresp control packet

func (*Pingresp) Buffers

func (p *Pingresp) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Pingresp) String added in v0.11.0

func (p *Pingresp) String() string

func (*Pingresp) Unpack

func (p *Pingresp) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Pingresp) WriteTo

func (p *Pingresp) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Properties

type Properties struct {
	// PayloadFormat indicates the format of the payload of the message
	// 0 is unspecified bytes
	// 1 is UTF8 encoded character data
	PayloadFormat *byte
	// MessageExpiry is the lifetime of the message in seconds
	MessageExpiry *uint32
	// ContentType is a UTF8 string describing the content of the message
	// for example it could be a MIME type
	ContentType string
	// ResponseTopic is a UTF8 string indicating the topic name to which any
	// response to this message should be sent
	ResponseTopic string
	// CorrelationData is binary data used to associate future response
	// messages with the original request message
	CorrelationData []byte
	// SubscriptionIdentifier is an identifier of the subscription to which
	// the Publish matched
	SubscriptionIdentifier *int
	// SessionExpiryInterval is the time in seconds after a client disconnects
	// that the server should retain the session information (subscriptions etc)
	SessionExpiryInterval *uint32
	// AssignedClientID is the server assigned client identifier in the case
	// that a client connected without specifying a clientID the server
	// generates one and returns it in the Connack
	AssignedClientID string
	// ServerKeepAlive allows the server to specify in the Connack packet
	// the time in seconds to be used as the keep alive value
	ServerKeepAlive *uint16
	// AuthMethod is a UTF8 string containing the name of the authentication
	// method to be used for extended authentication
	AuthMethod string
	// AuthData is binary data containing authentication data
	AuthData []byte
	// RequestProblemInfo is used by the Client to indicate to the server to
	// include the Reason String and/or User Properties in case of failures
	RequestProblemInfo *byte
	// WillDelayInterval is the number of seconds the server waits after the
	// point at which it would otherwise send the will message before sending
	// it. The client reconnecting before that time expires causes the server
	// to cancel sending the will
	WillDelayInterval *uint32
	// RequestResponseInfo is used by the Client to request the Server provide
	// Response Information in the Connack
	RequestResponseInfo *byte
	// ResponseInfo is a UTF8 encoded string that can be used as the basis for
	// createing a Response Topic. The way in which the Client creates a
	// Response Topic from the Response Information is not defined. A common
	// use of this is to pass a globally unique portion of the topic tree which
	// is reserved for this Client for at least the lifetime of its Session. This
	// often cannot just be a random name as both the requesting Client and the
	// responding Client need to be authorized to use it. It is normal to use this
	// as the root of a topic tree for a particular Client. For the Server to
	// return this information, it normally needs to be correctly configured.
	// Using this mechanism allows this configuration to be done once in the
	// Server rather than in each Client
	ResponseInfo string
	// ServerReference is a UTF8 string indicating another server the client
	// can use
	ServerReference string
	// ReasonString is a UTF8 string representing the reason associated with
	// this response, intended to be human readable for diagnostic purposes
	ReasonString string
	// ReceiveMaximum is the maximum number of QOS1 & 2 messages allowed to be
	// 'inflight' (not having received a PUBACK/PUBCOMP response for)
	ReceiveMaximum *uint16
	// TopicAliasMaximum is the highest value permitted as a Topic Alias
	TopicAliasMaximum *uint16
	// TopicAlias is used in place of the topic string to reduce the size of
	// packets for repeated messages on a topic
	TopicAlias *uint16
	// MaximumQOS is the highest QOS level permitted for a Publish
	MaximumQOS *byte
	// RetainAvailable indicates whether the server supports messages with the
	// retain flag set
	RetainAvailable *byte
	// User is a slice of user provided properties (key and value)
	User []User
	// MaximumPacketSize allows the client or server to specify the maximum packet
	// size in bytes that they support
	MaximumPacketSize *uint32
	// WildcardSubAvailable indicates whether wildcard subscriptions are permitted
	WildcardSubAvailable *byte
	// SubIDAvailable indicates whether subscription identifiers are supported
	SubIDAvailable *byte
	// SharedSubAvailable indicates whether shared subscriptions are supported
	SharedSubAvailable *byte
}

Properties is a struct representing the all the described properties allowed by the MQTT protocol, determining the validity of a property relvative to the packettype it was received in is provided by the ValidateID function

func (*Properties) Pack

func (i *Properties) Pack(p byte) []byte

Pack takes all the defined properties for an Properties and produces a slice of bytes representing the wire format for the information

func (*Properties) PackBuf added in v0.10.0

func (i *Properties) PackBuf(p byte) *bytes.Buffer

PackBuf will create a bytes.Buffer of the packed properties, it will only pack the properties appropriate to the packet type p even though other properties may exist, it will silently ignore them

func (*Properties) String added in v0.11.0

func (p *Properties) String() string

func (*Properties) Unpack

func (i *Properties) Unpack(r *bytes.Buffer, p byte) error

Unpack takes a buffer of bytes and reads out the defined properties filling in the appropriate entries in the struct, it returns the number of bytes used to store the Prop data and any error in decoding them

type Puback

type Puback struct {
	Properties *Properties
	PacketID   uint16
	ReasonCode byte
}

Puback is the Variable Header definition for a Puback control packet

func (*Puback) Buffers

func (p *Puback) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Puback) Reason

func (p *Puback) Reason() string

Reason returns a string representation of the meaning of the ReasonCode

func (*Puback) String added in v0.11.0

func (p *Puback) String() string

func (*Puback) Unpack

func (p *Puback) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Puback) WriteTo

func (p *Puback) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Pubcomp

type Pubcomp struct {
	Properties *Properties
	PacketID   uint16
	ReasonCode byte
}

Pubcomp is the Variable Header definition for a Pubcomp control packet

func (*Pubcomp) Buffers

func (p *Pubcomp) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Pubcomp) Reason

func (p *Pubcomp) Reason() string

Reason returns a string representation of the meaning of the ReasonCode

func (*Pubcomp) String added in v0.11.0

func (p *Pubcomp) String() string

func (*Pubcomp) Unpack

func (p *Pubcomp) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Pubcomp) WriteTo

func (p *Pubcomp) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Publish

type Publish struct {
	Payload    []byte
	Topic      string
	Properties *Properties
	PacketID   uint16
	QoS        byte
	Duplicate  bool
	Retain     bool
}

Publish is the Variable Header definition for a publish control packet

func (*Publish) Buffers

func (p *Publish) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Publish) SetIdentifier added in v0.12.0

func (p *Publish) SetIdentifier(packetID uint16)

SetIdentifier sets the packet identifier

func (*Publish) String added in v0.11.0

func (p *Publish) String() string

func (*Publish) ToControlPacket added in v0.12.0

func (p *Publish) ToControlPacket() *ControlPacket

ToControlPacket returns the packet as a ControlPacket

func (*Publish) Type added in v0.12.0

func (s *Publish) Type() byte

Type returns the current packet type

func (*Publish) Unpack

func (p *Publish) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Publish) WriteTo

func (p *Publish) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Pubrec

type Pubrec struct {
	Properties *Properties
	PacketID   uint16
	ReasonCode byte
}

Pubrec is the Variable Header definition for a Pubrec control packet

func (*Pubrec) Buffers

func (p *Pubrec) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Pubrec) Reason

func (p *Pubrec) Reason() string

Reason returns a string representation of the meaning of the ReasonCode

func (*Pubrec) String added in v0.11.0

func (p *Pubrec) String() string

func (*Pubrec) ToControlPacket added in v0.12.0

func (p *Pubrec) ToControlPacket() *ControlPacket

ToControlPacket returns the packet as a ControlPacket

func (*Pubrec) Unpack

func (p *Pubrec) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Pubrec) WriteTo

func (p *Pubrec) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Pubrel

type Pubrel struct {
	Properties *Properties
	PacketID   uint16
	ReasonCode byte
}

Pubrel is the Variable Header definition for a Pubrel control packet

func (*Pubrel) Buffers

func (p *Pubrel) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Pubrel) String added in v0.11.0

func (p *Pubrel) String() string

func (*Pubrel) Unpack

func (p *Pubrel) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Pubrel) WriteTo

func (p *Pubrel) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type SubOptions

type SubOptions struct {
	Topic             string
	QoS               byte
	RetainHandling    byte
	NoLocal           bool
	RetainAsPublished bool
}

SubOptions is the struct representing the options for a subscription

func (*SubOptions) Pack

func (s *SubOptions) Pack() byte

Pack is the implementation of the interface required function for a packet Note that this does not pack the topic

func (*SubOptions) Unpack

func (s *SubOptions) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet Note that this does not unpack the topic

type Suback

type Suback struct {
	Properties *Properties
	Reasons    []byte
	PacketID   uint16
}

Suback is the Variable Header definition for a Suback control packet

func (*Suback) Buffers

func (s *Suback) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Suback) Reason

func (s *Suback) Reason(index int) string

Reason returns a string representation of the meaning of the ReasonCode

func (*Suback) String added in v0.11.0

func (s *Suback) String() string

func (*Suback) Unpack

func (s *Suback) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Suback) WriteTo

func (s *Suback) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Subscribe

type Subscribe struct {
	Properties    *Properties
	Subscriptions []SubOptions
	PacketID      uint16
}

Subscribe is the Variable Header definition for a Subscribe control packet

func (*Subscribe) Buffers

func (s *Subscribe) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Subscribe) SetIdentifier added in v0.12.0

func (s *Subscribe) SetIdentifier(packetID uint16)

SetIdentifier sets the packet identifier

func (*Subscribe) String added in v0.11.0

func (s *Subscribe) String() string

func (*Subscribe) Type added in v0.12.0

func (s *Subscribe) Type() byte

Type returns the current packet type

func (*Subscribe) Unpack

func (s *Subscribe) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Subscribe) WriteTo

func (s *Subscribe) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Unsuback

type Unsuback struct {
	Reasons    []byte
	Properties *Properties
	PacketID   uint16
}

Unsuback is the Variable Header definition for a Unsuback control packet

func (*Unsuback) Buffers

func (u *Unsuback) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Unsuback) Reason

func (u *Unsuback) Reason(index int) string

Reason returns a string representation of the meaning of the ReasonCode

func (*Unsuback) String added in v0.11.0

func (u *Unsuback) String() string

func (*Unsuback) Unpack

func (u *Unsuback) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Unsuback) WriteTo

func (u *Unsuback) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type Unsubscribe

type Unsubscribe struct {
	Topics     []string
	Properties *Properties
	PacketID   uint16
}

Unsubscribe is the Variable Header definition for a Unsubscribe control packet

func (*Unsubscribe) Buffers

func (u *Unsubscribe) Buffers() net.Buffers

Buffers is the implementation of the interface required function for a packet

func (*Unsubscribe) SetIdentifier added in v0.12.0

func (u *Unsubscribe) SetIdentifier(packetID uint16)

SetIdentifier sets the packet identifier

func (*Unsubscribe) String added in v0.11.0

func (u *Unsubscribe) String() string

func (*Unsubscribe) Type added in v0.12.0

func (s *Unsubscribe) Type() byte

Type returns the current packet type

func (*Unsubscribe) Unpack

func (u *Unsubscribe) Unpack(r *bytes.Buffer) error

Unpack is the implementation of the interface required function for a packet

func (*Unsubscribe) WriteTo

func (u *Unsubscribe) WriteTo(w io.Writer) (int64, error)

WriteTo is the implementation of the interface required function for a packet

type User added in v0.10.0

type User struct {
	Key, Value string
}

User is a struct for the User properties, originally it was a map then it was pointed out that user properties are allowed to appear more than once

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL