Documentation ¶
Overview ¶
Package packet provides MQTT Control Packets.
Index ¶
- Constants
- Variables
- type CONNACK
- type CONNECT
- type CONNECTOptions
- type DISCONNECT
- type FixedHeader
- type PINGREQ
- type PINGRESP
- type PUBACK
- type PUBACKOptions
- type PUBCOMP
- type PUBCOMPOptions
- type PUBLISH
- type PUBLISHOptions
- type PUBREC
- type PUBRECOptions
- type PUBREL
- type PUBRELOptions
- type Packet
- func NewCONNACKFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
- func NewCONNECT(opts *CONNECTOptions) (Packet, error)
- func NewDISCONNECT() Packet
- func NewFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error)
- func NewPINGREQ() Packet
- func NewPINGRESPFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error)
- func NewPUBACK(opts *PUBACKOptions) (Packet, error)
- func NewPUBACKFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
- func NewPUBCOMP(opts *PUBCOMPOptions) (Packet, error)
- func NewPUBCOMPFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
- func NewPUBLISH(opts *PUBLISHOptions) (Packet, error)
- func NewPUBLISHFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error)
- func NewPUBREC(opts *PUBRECOptions) (Packet, error)
- func NewPUBRECFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
- func NewPUBREL(opts *PUBRELOptions) (Packet, error)
- func NewPUBRELFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
- func NewSUBACKFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error)
- func NewSUBSCRIBE(opts *SUBSCRIBEOptions) (Packet, error)
- func NewUNSUBACKFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
- func NewUNSUBSCRIBE(opts *UNSUBSCRIBEOptions) (Packet, error)
- type SUBACK
- type SUBSCRIBE
- type SUBSCRIBEOptions
- type SubReq
- type UNSUBACK
- type UNSUBSCRIBE
- type UNSUBSCRIBEOptions
Constants ¶
const ( TypeCONNECT byte = 0x01 TypeCONNACK byte = 0x02 TypePUBLISH byte = 0x03 TypePUBACK byte = 0x04 TypePUBREC byte = 0x05 TypePUBREL byte = 0x06 TypePUBCOMP byte = 0x07 TypeSUBSCRIBE byte = 0x08 TypeSUBACK byte = 0x09 TypeUNSUBSCRIBE byte = 0x0A TypeUNSUBACK byte = 0x0B TypePINGREQ byte = 0x0C TypePINGRESP byte = 0x0D TypeDISCONNECT byte = 0x0E )
MQTT Control Packet types
const SUBACKRetFailure byte = 0x80
Return Code Failure
Variables ¶
var ( ErrInvalidFixedHeader = errors.New("invalid fixed header") ErrInvalidVariableHeaderLen = errors.New("invalid length of the variable header") ErrInvalidRemainingLen = errors.New("invalid length of the remaining") ErrInvalidVariableHeader = errors.New("invalid variable header") ErrInvalidRemainingLength = errors.New("invalid Remaining Length") ErrInvalidConnectReturnCode = errors.New("invalid Connect Return code") )
Error values
var ( ErrClientIDExceedsMaxStringsLen = errors.New("the length of the Client Identifier exceeds the maximum strings legnth") ErrUserNameExceedsMaxStringsLen = errors.New("the length of the User Name exceeds the maximum strings legnth") ErrPasswordExceedsMaxStringsLen = errors.New("the length of the Password exceeds the maximum strings legnth") ErrWillTopicExceedsMaxStringsLen = errors.New("the length of the Will Topic exceeds the maximum strings legnth") ErrWillMessageExceedsMaxStringsLen = errors.New("the length of the Will Message exceeds the maximum strings legnth") ErrInvalidClientIDCleanSession = errors.New("the Clean Session must be true if the Client Identifier is zero-byte") ErrInvalidClientIDPassword = errors.New("the Password must be zero-byte if the Client Identifier is zero-byte") ErrInvalidWillTopicMessage = errors.New("the Will Topic (Message) must not be zero-byte if the Will Message (Topic) is not zero-byte") ErrInvalidWillQoS = errors.New("the Will QoS is invalid") ErrInvalidWillTopicMessageQoS = errors.New("the Will QoS must be zero if both the Will Topic and the Will Message are zero-byte") ErrInvalidWillTopicMessageRetain = errors.New("the Will Retain must be false if both the Will Topic and the Will Message are zero-byte") )
Error values
var ( ErrInvalidQoS = errors.New("the QoS is invalid") ErrTopicNameExceedsMaxStringsLen = errors.New("the length of the Topic Name exceeds the maximum strings legnth") ErrTopicNameContainsWildcards = errors.New("the Topic Name contains wildcard characters") ErrMessageExceedsMaxStringsLen = errors.New("the length of the Message exceeds the maximum strings legnth") )
Error values
var ( ErrNoTopicFilter = errors.New("the Topic Filter must be specified") ErrTopicFilterExceedsMaxStringsLen = errors.New("the length of the Topic Filter exceeds the maximum strings legnth") )
Error values
var ErrInvalidByteLen = errors.New("invalid byte length")
Error value
var ErrInvalidFixedHeaderLen = errors.New("the length of the fixed header is invalid")
Error value
var ErrInvalidNoSubReq = errors.New("subscription request must be specified")
Error value
var ErrInvalidPacketID = errors.New("invalid Packet Identifier")
Error value
var ErrInvalidPacketType = errors.New("invalid MQTT Control Packet type")
Error value
var ErrInvalidSUBACKReturnCode = errors.New("invalid SUBACK Return Code")
Error value
Functions ¶
This section is empty.
Types ¶
type CONNACK ¶
type CONNACK struct {
// contains filtered or unexported fields
}
CONNACK represents a CONNACK Packet.
type CONNECT ¶
type CONNECT struct {
// contains filtered or unexported fields
}
CONNECT represents a CONNECT Packet.
type CONNECTOptions ¶
type CONNECTOptions struct { // ClientID is the Client Identifier of the payload. ClientID []byte // UserName is the User Name of the payload. UserName []byte // Password is the Password of the payload. Password []byte // CleanSession is the Clean Session of the variable header. CleanSession bool // KeepAlive is the Keep Alive of the variable header. KeepAlive uint16 // WillTopic is the Will Topic of the payload. WillTopic []byte // WillMessage is the Will Message of the payload. WillMessage []byte // WillQoS is the Will QoS of the variable header. WillQoS byte // WillRetain is the Will Retain of the variable header. WillRetain bool }
CONNECTOptions represents options for a CONNECT Packet.
type DISCONNECT ¶
type DISCONNECT struct {
// contains filtered or unexported fields
}
DISCONNECT represents a DISCONNECT Packet.
type PINGREQ ¶
type PINGREQ struct {
// contains filtered or unexported fields
}
PINGREQ represents a PINGREQ Packet.
type PINGRESP ¶
type PINGRESP struct {
// contains filtered or unexported fields
}
PINGRESP represents a PINGRESP Packet.
type PUBACK ¶
type PUBACK struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // contains filtered or unexported fields }
PUBACK represents a PUBACK Packet.
type PUBACKOptions ¶
type PUBACKOptions struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 }
PUBACKOptions represents options for a PUBACK Packet.
type PUBCOMP ¶
type PUBCOMP struct { // packetID is the Packet Identifier of the variable header. PacketID uint16 // contains filtered or unexported fields }
PUBCOMP represents a PUBCOMP Packet.
type PUBCOMPOptions ¶
type PUBCOMPOptions struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 }
PUBCOMPOptions represents options for a PUBCOMP Packet.
type PUBLISH ¶
type PUBLISH struct { // dup is the DUP flag of the fixed header. DUP bool // qos is the QoS of the fixed header. QoS byte // topicName is the Topic Name of the varible header. TopicName []byte // packetID is the Packet Identifier of the variable header. PacketID uint16 // message is the Application Message of the payload. Message []byte // contains filtered or unexported fields }
PUBLISH represents a PUBLISH Packet.
type PUBLISHOptions ¶
type PUBLISHOptions struct { // DUP is the DUP flag of the fixed header. DUP bool // QoS is the QoS of the fixed header. QoS byte // Retain is the Retain of the fixed header. Retain bool // TopicName is the Topic Name of the varible header. TopicName []byte // PacketID is the Packet Identifier of the variable header. PacketID uint16 // Message is the Application Message of the payload. Message []byte }
PUBLISHOptions represents options for a PUBLISH Packet.
type PUBREC ¶
type PUBREC struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // contains filtered or unexported fields }
PUBREC represents a PUBREC Packet.
type PUBRECOptions ¶
type PUBRECOptions struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 }
PUBRECOptions represents options for a PUBREC Packet.
type PUBREL ¶
type PUBREL struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // contains filtered or unexported fields }
PUBREL represents a PUBREL Packet.
type PUBRELOptions ¶
type PUBRELOptions struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 }
PUBRELOptions represents options for a PUBREL Packet.
type Packet ¶
type Packet interface { io.WriterTo // Type returns the MQTT Control Packet type of the Packet. Type() (byte, error) }
Packet represents an MQTT Control Packet.
func NewCONNACKFromBytes ¶
func NewCONNACKFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
NewCONNACKFromBytes creates the CONNACK Packet from the byte data and returns it.
func NewCONNECT ¶
func NewCONNECT(opts *CONNECTOptions) (Packet, error)
NewCONNECT creates and returns a CONNECT Packet.
func NewDISCONNECT ¶
func NewDISCONNECT() Packet
NewDISCONNECT creates and returns a DISCONNECT Packet.
func NewFromBytes ¶
func NewFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error)
NewFromBytes creates a Packet from the byte data and returns it.
func NewPINGRESPFromBytes ¶
func NewPINGRESPFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error)
NewPINGRESPFromBytes creates a PINGRESP Packet from the byte data and returns it.
func NewPUBACK ¶
func NewPUBACK(opts *PUBACKOptions) (Packet, error)
NewPUBACK creates and returns a PUBACK Packet.
func NewPUBACKFromBytes ¶
func NewPUBACKFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
NewPUBACKFromBytes creates a PUBACK Packet from the byte data and returns it.
func NewPUBCOMP ¶
func NewPUBCOMP(opts *PUBCOMPOptions) (Packet, error)
NewPUBCOMP creates and returns a PUBCOMP Packet.
func NewPUBCOMPFromBytes ¶
func NewPUBCOMPFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
NewPUBCOMPFromBytes creates a PUBCOMP Packet from the byte data and returns it.
func NewPUBLISH ¶
func NewPUBLISH(opts *PUBLISHOptions) (Packet, error)
NewPUBLISH creates and returns a PUBLISH Packet.
func NewPUBLISHFromBytes ¶
func NewPUBLISHFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error)
NewPUBLISHFromBytes creates the PUBLISH Packet from the byte data and returns it.
func NewPUBREC ¶
func NewPUBREC(opts *PUBRECOptions) (Packet, error)
NewPUBREC creates and returns a PUBACK Packet.
func NewPUBRECFromBytes ¶
func NewPUBRECFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
NewPUBRECFromBytes creates a PUBREC Packet from the byte data and returns it.
func NewPUBREL ¶
func NewPUBREL(opts *PUBRELOptions) (Packet, error)
NewPUBREL creates and returns a PUBREL Packet.
func NewPUBRELFromBytes ¶
func NewPUBRELFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
NewPUBRELFromBytes creates a PUBREL Packet from the byte data and returns it.
func NewSUBACKFromBytes ¶
func NewSUBACKFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error)
NewSUBACKFromBytes creates a SUBACK Packet from the byte data and returns it.
func NewSUBSCRIBE ¶
func NewSUBSCRIBE(opts *SUBSCRIBEOptions) (Packet, error)
NewSUBSCRIBE creates and returns a SUBSCRIBE Packet.
func NewUNSUBACKFromBytes ¶
func NewUNSUBACKFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error)
NewUNSUBACKFromBytes creates an UNSUBACK Packet from the byte data and returns it.
func NewUNSUBSCRIBE ¶
func NewUNSUBSCRIBE(opts *UNSUBSCRIBEOptions) (Packet, error)
NewUNSUBSCRIBE creates and returns an UNSUBSCRIBE Packet.
type SUBACK ¶
type SUBACK struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // ReturnCodes is the Return Codes of the payload. ReturnCodes []byte // contains filtered or unexported fields }
SUBACK represents a SUBACK Packet.
type SUBSCRIBE ¶
type SUBSCRIBE struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // SubReqs is a slice of the subscription requests. SubReqs []*SubReq // contains filtered or unexported fields }
SUBSCRIBE represents a SUBSCRIBE Packet.
type SUBSCRIBEOptions ¶
type SUBSCRIBEOptions struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // SubReqs is a slice of the subscription requests. SubReqs []*SubReq }
SUBSCRIBEOptions represents options for a SUBSCRIBE Packet.
type SubReq ¶
type SubReq struct { // TopicFilter is the Topic Filter of the Subscription. TopicFilter []byte // QoS is the requsting QoS. QoS byte }
SubReq represents subscription request.
type UNSUBACK ¶
type UNSUBACK struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // contains filtered or unexported fields }
UNSUBACK represents an UNSUBACK Packet.
type UNSUBSCRIBE ¶
type UNSUBSCRIBE struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // TopicFilters represents a slice of the Topic Filters TopicFilters [][]byte // contains filtered or unexported fields }
UNSUBSCRIBE represents an UNSUBSCRIBE Packet.
type UNSUBSCRIBEOptions ¶
type UNSUBSCRIBEOptions struct { // PacketID is the Packet Identifier of the variable header. PacketID uint16 // TopicFilters represents a slice of the Topic Filters TopicFilters [][]byte }
UNSUBSCRIBEOptions represents options for an UNSUBSCRIBE Packet.
Source Files ¶
- base.go
- connack.go
- connect.go
- connect_options.go
- decode.go
- disconnect.go
- doc.go
- encode.go
- fixed_header.go
- packet.go
- pingreq.go
- pingresp.go
- puback.go
- puback_options.go
- pubcomp.go
- pubcomp_options.go
- publish.go
- publish_options.go
- pubrec.go
- pubrec_options.go
- pubrel.go
- pubrel_options.go
- strings.go
- sub_req.go
- suback.go
- subscribe.go
- subscribe_options.go
- types.go
- unsuback.go
- unsubscribe.go
- unsubscribe_options.go