Documentation ¶
Index ¶
- Constants
- Variables
- func Encode(p Provider) ([]byte, error)
- func ReadLPBytes(buf []byte) ([]byte, int, error)
- func ValidTopic(topic string) bool
- func WriteLPBytes(buf []byte, b []byte) (int, error)
- type Ack
- func (h *Ack) Desc() string
- func (h *Ack) Encode(to []byte) (int, error)
- func (h *Ack) Flags() byte
- func (h *Ack) ID() (IDType, error)
- func (h *Ack) Name() string
- func (h *Ack) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *Ack) PropertyGet(id PropertyID) PropertyToType
- func (h *Ack) PropertySet(id PropertyID, val interface{}) error
- func (msg *Ack) Reason() ReasonCode
- func (h *Ack) RemainingLength() int32
- func (msg *Ack) SetPacketID(v IDType)
- func (msg *Ack) SetReason(c ReasonCode)
- func (h *Ack) SetVersion(v ProtocolVersion)
- func (h *Ack) Size() (int, error)
- func (h *Ack) Type() Type
- func (h *Ack) Version() ProtocolVersion
- type Auth
- func (h *Auth) Desc() string
- func (h *Auth) Encode(to []byte) (int, error)
- func (h *Auth) Flags() byte
- func (h *Auth) ID() (IDType, error)
- func (h *Auth) Name() string
- func (h *Auth) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *Auth) PropertyGet(id PropertyID) PropertyToType
- func (h *Auth) PropertySet(id PropertyID, val interface{}) error
- func (msg *Auth) ReasonCode() ReasonCode
- func (h *Auth) RemainingLength() int32
- func (msg *Auth) SetReasonCode(c ReasonCode) error
- func (h *Auth) SetVersion(v ProtocolVersion)
- func (h *Auth) Size() (int, error)
- func (h *Auth) Type() Type
- func (h *Auth) Version() ProtocolVersion
- type CodeIssuer
- type ConnAck
- func (h *ConnAck) Desc() string
- func (h *ConnAck) Encode(to []byte) (int, error)
- func (h *ConnAck) Flags() byte
- func (h *ConnAck) ID() (IDType, error)
- func (h *ConnAck) Name() string
- func (h *ConnAck) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *ConnAck) PropertyGet(id PropertyID) PropertyToType
- func (h *ConnAck) PropertySet(id PropertyID, val interface{}) error
- func (h *ConnAck) RemainingLength() int32
- func (msg *ConnAck) ReturnCode() ReasonCode
- func (msg *ConnAck) SessionPresent() bool
- func (msg *ConnAck) SetReturnCode(ret ReasonCode) error
- func (msg *ConnAck) SetSessionPresent(v bool)
- func (h *ConnAck) SetVersion(v ProtocolVersion)
- func (h *ConnAck) Size() (int, error)
- func (h *ConnAck) Type() Type
- func (h *ConnAck) Version() ProtocolVersion
- type Connect
- func (msg *Connect) ClientID() []byte
- func (msg *Connect) Credentials() ([]byte, []byte)
- func (h *Connect) Desc() string
- func (h *Connect) Encode(to []byte) (int, error)
- func (h *Connect) Flags() byte
- func (h *Connect) ID() (IDType, error)
- func (msg *Connect) IsClean() bool
- func (msg *Connect) KeepAlive() uint16
- func (h *Connect) Name() string
- func (h *Connect) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *Connect) PropertyGet(id PropertyID) PropertyToType
- func (h *Connect) PropertySet(id PropertyID, val interface{}) error
- func (h *Connect) RemainingLength() int32
- func (msg *Connect) ResetWill()
- func (msg *Connect) SetClean(v bool)
- func (msg *Connect) SetClientID(v []byte) error
- func (msg *Connect) SetCredentials(u []byte, p []byte) error
- func (msg *Connect) SetKeepAlive(v uint16)
- func (h *Connect) SetVersion(v ProtocolVersion)
- func (msg *Connect) SetWill(t string, m []byte, qos QosType, retain bool) error
- func (h *Connect) Size() (int, error)
- func (h *Connect) Type() Type
- func (h *Connect) Version() ProtocolVersion
- func (msg *Connect) Will() (string, []byte, QosType, bool, bool)
- type Disconnect
- func (h *Disconnect) Desc() string
- func (h *Disconnect) Encode(to []byte) (int, error)
- func (h *Disconnect) Flags() byte
- func (h *Disconnect) ID() (IDType, error)
- func (h *Disconnect) Name() string
- func (h *Disconnect) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *Disconnect) PropertyGet(id PropertyID) PropertyToType
- func (h *Disconnect) PropertySet(id PropertyID, val interface{}) error
- func (msg *Disconnect) ReasonCode() ReasonCode
- func (h *Disconnect) RemainingLength() int32
- func (msg *Disconnect) SetReasonCode(c ReasonCode)
- func (h *Disconnect) SetVersion(v ProtocolVersion)
- func (h *Disconnect) Size() (int, error)
- func (h *Disconnect) Type() Type
- func (h *Disconnect) Version() ProtocolVersion
- type Error
- type IDType
- type PingReq
- func (h *PingReq) Desc() string
- func (h *PingReq) Encode(to []byte) (int, error)
- func (h *PingReq) Flags() byte
- func (h *PingReq) ID() (IDType, error)
- func (h *PingReq) Name() string
- func (h *PingReq) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *PingReq) PropertyGet(id PropertyID) PropertyToType
- func (h *PingReq) PropertySet(id PropertyID, val interface{}) error
- func (h *PingReq) RemainingLength() int32
- func (h *PingReq) SetVersion(v ProtocolVersion)
- func (h *PingReq) Size() (int, error)
- func (h *PingReq) Type() Type
- func (h *PingReq) Version() ProtocolVersion
- type PingResp
- func (h *PingResp) Desc() string
- func (h *PingResp) Encode(to []byte) (int, error)
- func (h *PingResp) Flags() byte
- func (h *PingResp) ID() (IDType, error)
- func (h *PingResp) Name() string
- func (h *PingResp) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *PingResp) PropertyGet(id PropertyID) PropertyToType
- func (h *PingResp) PropertySet(id PropertyID, val interface{}) error
- func (h *PingResp) RemainingLength() int32
- func (h *PingResp) SetVersion(v ProtocolVersion)
- func (h *PingResp) Size() (int, error)
- func (h *PingResp) Type() Type
- func (h *PingResp) Version() ProtocolVersion
- type PropertyError
- type PropertyID
- type PropertyToType
- type PropertyType
- type ProtocolVersion
- type Provider
- type Publish
- func (msg *Publish) Clone(v ProtocolVersion) (*Publish, error)
- func (h *Publish) Desc() string
- func (msg *Publish) Dup() bool
- func (h *Publish) Encode(to []byte) (int, error)
- func (msg *Publish) Expired(set bool) bool
- func (h *Publish) Flags() byte
- func (msg *Publish) GetExpiry() *time.Time
- func (h *Publish) ID() (IDType, error)
- func (h *Publish) Name() string
- func (msg *Publish) Payload() []byte
- func (h *Publish) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *Publish) PropertyGet(id PropertyID) PropertyToType
- func (h *Publish) PropertySet(id PropertyID, val interface{}) error
- func (msg *Publish) PublishID() uintptr
- func (msg *Publish) QoS() QosType
- func (h *Publish) RemainingLength() int32
- func (msg *Publish) Retain() bool
- func (msg *Publish) Set(t string, p []byte, q QosType, r bool, d bool) error
- func (msg *Publish) SetDup(v bool)
- func (msg *Publish) SetExpiry(tm time.Time)
- func (msg *Publish) SetPacketID(v IDType)
- func (msg *Publish) SetPayload(v []byte)
- func (msg *Publish) SetPublishID(id uintptr)
- func (msg *Publish) SetQoS(v QosType) error
- func (msg *Publish) SetRetain(v bool)
- func (msg *Publish) SetTopic(v string) error
- func (h *Publish) SetVersion(v ProtocolVersion)
- func (h *Publish) Size() (int, error)
- func (msg *Publish) Topic() string
- func (h *Publish) Type() Type
- func (h *Publish) Version() ProtocolVersion
- type QosType
- type ReasonCode
- func (c ReasonCode) Desc() string
- func (c ReasonCode) Error() string
- func (c ReasonCode) IsValid() bool
- func (c ReasonCode) IsValidForType(p Type) bool
- func (c ReasonCode) IsValidV3() bool
- func (c ReasonCode) IsValidV5() bool
- func (c ReasonCode) PacketTypeDir(p Type) (CodeIssuer, error)
- func (c ReasonCode) Value() byte
- type RetainHandling
- type StringPair
- type SubAck
- func (msg *SubAck) AddReturnCode(ret ReasonCode) error
- func (msg *SubAck) AddReturnCodes(ret []ReasonCode) error
- func (h *SubAck) Desc() string
- func (h *SubAck) Encode(to []byte) (int, error)
- func (h *SubAck) Flags() byte
- func (h *SubAck) ID() (IDType, error)
- func (h *SubAck) Name() string
- func (h *SubAck) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *SubAck) PropertyGet(id PropertyID) PropertyToType
- func (h *SubAck) PropertySet(id PropertyID, val interface{}) error
- func (h *SubAck) RemainingLength() int32
- func (msg *SubAck) ReturnCodes() []ReasonCode
- func (msg *SubAck) SetPacketID(v IDType)
- func (h *SubAck) SetVersion(v ProtocolVersion)
- func (h *SubAck) Size() (int, error)
- func (h *SubAck) Type() Type
- func (h *SubAck) Version() ProtocolVersion
- type Subscribe
- func (msg *Subscribe) AddTopic(topic string, ops SubscriptionOptions) error
- func (h *Subscribe) Desc() string
- func (h *Subscribe) Encode(to []byte) (int, error)
- func (h *Subscribe) Flags() byte
- func (h *Subscribe) ID() (IDType, error)
- func (h *Subscribe) Name() string
- func (h *Subscribe) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *Subscribe) PropertyGet(id PropertyID) PropertyToType
- func (h *Subscribe) PropertySet(id PropertyID, val interface{}) error
- func (h *Subscribe) RemainingLength() int32
- func (msg *Subscribe) RemoveTopic(topic string)
- func (msg *Subscribe) SetPacketID(v IDType)
- func (h *Subscribe) SetVersion(v ProtocolVersion)
- func (h *Subscribe) Size() (int, error)
- func (msg *Subscribe) Topics() omap.Map
- func (h *Subscribe) Type() Type
- func (h *Subscribe) Version() ProtocolVersion
- type SubscriptionOptions
- type TopicQos
- type Type
- type UnSubAck
- func (msg *UnSubAck) AddReturnCode(ret ReasonCode) error
- func (msg *UnSubAck) AddReturnCodes(ret []ReasonCode) error
- func (h *UnSubAck) Desc() string
- func (h *UnSubAck) Encode(to []byte) (int, error)
- func (h *UnSubAck) Flags() byte
- func (h *UnSubAck) ID() (IDType, error)
- func (h *UnSubAck) Name() string
- func (h *UnSubAck) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *UnSubAck) PropertyGet(id PropertyID) PropertyToType
- func (h *UnSubAck) PropertySet(id PropertyID, val interface{}) error
- func (h *UnSubAck) RemainingLength() int32
- func (msg *UnSubAck) ReturnCodes() []ReasonCode
- func (msg *UnSubAck) SetPacketID(v IDType)
- func (h *UnSubAck) SetVersion(v ProtocolVersion)
- func (h *UnSubAck) Size() (int, error)
- func (h *UnSubAck) Type() Type
- func (h *UnSubAck) Version() ProtocolVersion
- type UnSubscribe
- func (msg *UnSubscribe) AddTopic(topic string) error
- func (h *UnSubscribe) Desc() string
- func (h *UnSubscribe) Encode(to []byte) (int, error)
- func (h *UnSubscribe) Flags() byte
- func (h *UnSubscribe) ID() (IDType, error)
- func (h *UnSubscribe) Name() string
- func (h *UnSubscribe) PropertyForEach(f func(PropertyID, PropertyToType)) error
- func (h *UnSubscribe) PropertyGet(id PropertyID) PropertyToType
- func (h *UnSubscribe) PropertySet(id PropertyID, val interface{}) error
- func (h *UnSubscribe) RemainingLength() int32
- func (msg *UnSubscribe) RemoveTopic(topic string)
- func (msg *UnSubscribe) SetPacketID(v IDType)
- func (h *UnSubscribe) SetVersion(v ProtocolVersion)
- func (h *UnSubscribe) Size() (int, error)
- func (msg *UnSubscribe) Topics() omap.Map
- func (h *UnSubscribe) Type() Type
- func (h *UnSubscribe) Version() ProtocolVersion
Constants ¶
const ( PropertyPayloadFormat = PropertyID(0x01) PropertyPublicationExpiry = PropertyID(0x02) PropertyContentType = PropertyID(0x03) PropertyResponseTopic = PropertyID(0x08) PropertyCorrelationData = PropertyID(0x09) PropertySubscriptionIdentifier = PropertyID(0x0B) PropertySessionExpiryInterval = PropertyID(0x11) PropertyAssignedClientIdentifier = PropertyID(0x12) PropertyServerKeepAlive = PropertyID(0x13) PropertyAuthMethod = PropertyID(0x15) PropertyAuthData = PropertyID(0x16) PropertyRequestProblemInfo = PropertyID(0x17) PropertyWillDelayInterval = PropertyID(0x18) PropertyRequestResponseInfo = PropertyID(0x19) PropertyResponseInfo = PropertyID(0x1A) PropertyServerReverence = PropertyID(0x1C) PropertyReasonString = PropertyID(0x1F) PropertyReceiveMaximum = PropertyID(0x21) PropertyTopicAliasMaximum = PropertyID(0x22) PropertyTopicAlias = PropertyID(0x23) PropertyMaximumQoS = PropertyID(0x24) PropertyRetainAvailable = PropertyID(0x25) PropertyUserProperty = PropertyID(0x26) PropertyMaximumPacketSize = PropertyID(0x27) PropertyWildcardSubscriptionAvailable = PropertyID(0x28) PropertySubscriptionIdentifierAvailable = PropertyID(0x29) )
nolint: golint
const ( PropertyTypeByte = iota PropertyTypeShort PropertyTypeInt PropertyTypeVarInt PropertyTypeString PropertyTypeStringPair PropertyTypeBinary )
nolint: golint
const ( // ProtocolV31 describes spec MQIsdp ProtocolV31 = ProtocolVersion(0x3) // ProtocolV311 describes spec v3.1.1 ProtocolV311 = ProtocolVersion(0x4) // ProtocolV50 describes spec v5.0 ProtocolV50 = ProtocolVersion(0x5) )
const (
// MaxLPString maximum size of length-prefixed string
MaxLPString = 65535
)
Variables ¶
var SupportedVersions = map[ProtocolVersion]string{ ProtocolV31: "MQIsdp", ProtocolV311: "MQTT", ProtocolV50: "MQTT", }
SupportedVersions is a map of the version number (0x3 or 0x4) to the version string, "MQIsdp" for 0x3, and "MQTT" for 0x4.
Functions ¶
func ReadLPBytes ¶
ReadLPBytes read length prefixed bytes
func ValidTopic ¶
ValidTopic checks the topic, which is a slice of bytes, to see if it's valid. Topic is considered valid if it's longer than 0 bytes, and doesn't contain any wildcard characters such as + and #.
Types ¶
type Ack ¶
type Ack struct {
// contains filtered or unexported fields
}
Ack acknowledge packets for PUBLISH messages A PUBACK Packet is the response to a PUBLISH Packet with QoS level 1 A PUBREC/PUBREL/PUBCOMP Packet is the response to a PUBLISH Packet with QoS level 2
func (*Ack) Desc ¶
func (h *Ack) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*Ack) Flags ¶
func (h *Ack) Flags() byte
Flags returns the fixed header flags for this message.
func (*Ack) Name ¶
func (h *Ack) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*Ack) PropertyForEach ¶
func (h *Ack) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*Ack) PropertyGet ¶
func (h *Ack) PropertyGet(id PropertyID) PropertyToType
func (*Ack) PropertySet ¶
func (h *Ack) PropertySet(id PropertyID, val interface{}) error
func (*Ack) RemainingLength ¶
func (h *Ack) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*Ack) SetPacketID ¶
SetPacketID sets the ID of the packet.
func (*Ack) SetVersion ¶
func (h *Ack) SetVersion(v ProtocolVersion)
func (*Ack) Version ¶
func (h *Ack) Version() ProtocolVersion
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth The CONNACK Packet is the packet sent by the Server in response to a CONNECT Packet received from a Client. The first packet sent from the Server to the Client MUST be a CONNACK Packet [MQTT-3.2.0-1]. If the Client does not receive a CONNACK Packet from the Server within a reasonable amount of time, the Client SHOULD close the Network Connection. A "reasonable" amount of time depends on the type of application and the communications infrastructure.
func (*Auth) Desc ¶
func (h *Auth) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*Auth) Flags ¶
func (h *Auth) Flags() byte
Flags returns the fixed header flags for this message.
func (*Auth) Name ¶
func (h *Auth) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*Auth) PropertyForEach ¶
func (h *Auth) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*Auth) PropertyGet ¶
func (h *Auth) PropertyGet(id PropertyID) PropertyToType
func (*Auth) PropertySet ¶
func (h *Auth) PropertySet(id PropertyID, val interface{}) error
func (*Auth) ReasonCode ¶
func (msg *Auth) ReasonCode() ReasonCode
ReasonCode get authentication reason
func (*Auth) RemainingLength ¶
func (h *Auth) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*Auth) SetReasonCode ¶
func (msg *Auth) SetReasonCode(c ReasonCode) error
SetReasonCode set authentication reason code
func (*Auth) SetVersion ¶
func (h *Auth) SetVersion(v ProtocolVersion)
func (*Auth) Version ¶
func (h *Auth) Version() ProtocolVersion
type CodeIssuer ¶
type CodeIssuer byte
CodeIssuer who is message issuer
const ( CodeIssuerServer CodeIssuer = 0x00 CodeIssuerClient CodeIssuerBoth CodeIssuerInvalid )
nolint: golint
type ConnAck ¶
type ConnAck struct {
// contains filtered or unexported fields
}
ConnAck The CONNACK Packet is the packet sent by the Server in response to a CONNECT Packet received from a Client. The first packet sent from the Server to the Client MUST be a CONNACK Packet [MQTT-3.2.0-1]. If the Client does not receive a CONNACK Packet from the Server within a reasonable amount of time, the Client SHOULD close the Network Connection. A "reasonable" amount of time depends on the type of application and the communications infrastructure.
func (*ConnAck) Desc ¶
func (h *ConnAck) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*ConnAck) Flags ¶
func (h *ConnAck) Flags() byte
Flags returns the fixed header flags for this message.
func (*ConnAck) Name ¶
func (h *ConnAck) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*ConnAck) PropertyForEach ¶
func (h *ConnAck) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*ConnAck) PropertyGet ¶
func (h *ConnAck) PropertyGet(id PropertyID) PropertyToType
func (*ConnAck) PropertySet ¶
func (h *ConnAck) PropertySet(id PropertyID, val interface{}) error
func (*ConnAck) RemainingLength ¶
func (h *ConnAck) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*ConnAck) ReturnCode ¶
func (msg *ConnAck) ReturnCode() ReasonCode
ReturnCode returns the return code received for the CONNECT message. The return type is an error
func (*ConnAck) SessionPresent ¶
SessionPresent returns the session present flag value
func (*ConnAck) SetReturnCode ¶
func (msg *ConnAck) SetReturnCode(ret ReasonCode) error
SetReturnCode of conn
func (*ConnAck) SetSessionPresent ¶
SetSessionPresent sets the value of the session present flag
func (*ConnAck) SetVersion ¶
func (h *ConnAck) SetVersion(v ProtocolVersion)
func (*ConnAck) Version ¶
func (h *ConnAck) Version() ProtocolVersion
type Connect ¶
type Connect struct {
// contains filtered or unexported fields
}
Connect After a Network Connection is established by a Client to a Server, the first Packet sent from the Client to the Server MUST be a CONNECT Packet [MQTT-3.1.0-1].
A Client can only send the CONNECT Packet once over a Network Connection. The Server MUST process a second CONNECT Packet sent from a Client as a protocol violation and disconnect the Client [MQTT-3.1.0-2]. See section 4.8 for information about handling errors.
func (*Connect) ClientID ¶
ClientID returns an ID that identifies the Client to the Server. Each Client connecting to the Server has a unique ClientId. The ClientId MUST be used by Clients and by Servers to identify state that they hold relating to this MQTT Session between the Client and the Server
func (*Connect) Credentials ¶
Credentials returns user and password
func (*Connect) Desc ¶
func (h *Connect) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*Connect) Flags ¶
func (h *Connect) Flags() byte
Flags returns the fixed header flags for this message.
func (*Connect) IsClean ¶
IsClean returns the bit that specifies the handling of the Session state. The Client and Server can store Session state to enable reliable messaging to continue across a sequence of Network Connections. This bit is used to control the lifetime of the Session state.
func (*Connect) KeepAlive ¶
KeepAlive returns a time interval measured in seconds. Expressed as a 16-bit word, it is the maximum time interval that is permitted to elapse between the point at which the Client finishes transmitting one Control Packet and the point it starts sending the next.
func (*Connect) Name ¶
func (h *Connect) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*Connect) PropertyForEach ¶
func (h *Connect) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*Connect) PropertyGet ¶
func (h *Connect) PropertyGet(id PropertyID) PropertyToType
func (*Connect) PropertySet ¶
func (h *Connect) PropertySet(id PropertyID, val interface{}) error
func (*Connect) RemainingLength ¶
func (h *Connect) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*Connect) SetClientID ¶
SetClientID sets an ID that identifies the Client to the Server.
func (*Connect) SetCredentials ¶
SetCredentials set username and password
func (*Connect) SetKeepAlive ¶
SetKeepAlive sets the time interval in which the server should keep the connection alive.
func (*Connect) SetVersion ¶
func (h *Connect) SetVersion(v ProtocolVersion)
func (*Connect) Version ¶
func (h *Connect) Version() ProtocolVersion
type Disconnect ¶
type Disconnect struct {
// contains filtered or unexported fields
}
Disconnect The DISCONNECT Packet is the final Control Packet sent from the Client to the Server. It indicates that the Client is disconnecting cleanly.
func (*Disconnect) Desc ¶
func (h *Disconnect) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*Disconnect) Flags ¶
func (h *Disconnect) Flags() byte
Flags returns the fixed header flags for this message.
func (*Disconnect) Name ¶
func (h *Disconnect) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*Disconnect) PropertyForEach ¶
func (h *Disconnect) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*Disconnect) PropertyGet ¶
func (h *Disconnect) PropertyGet(id PropertyID) PropertyToType
func (*Disconnect) PropertySet ¶
func (h *Disconnect) PropertySet(id PropertyID, val interface{}) error
func (*Disconnect) ReasonCode ¶
func (msg *Disconnect) ReasonCode() ReasonCode
ReasonCode get disconnect reason
func (*Disconnect) RemainingLength ¶
func (h *Disconnect) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*Disconnect) SetReasonCode ¶
func (msg *Disconnect) SetReasonCode(c ReasonCode)
SetReasonCode set disconnect reason
func (*Disconnect) SetVersion ¶
func (h *Disconnect) SetVersion(v ProtocolVersion)
func (*Disconnect) Type ¶
func (h *Disconnect) Type() Type
Type returns the MessageType of the Message
func (*Disconnect) Version ¶
func (h *Disconnect) Version() ProtocolVersion
type Error ¶
type Error byte
Error errors
const ( // ErrInvalidUnSubscribe Invalid UNSUBSCRIBE message ErrInvalidUnSubscribe Error = iota // ErrInvalidUnSubAck Invalid UNSUBACK message ErrInvalidUnSubAck // ErrPackedIDNotMatched Packet ID does not match ErrDupViolation ErrPackedIDNotMatched ErrInvalid // ErrPackedIDZero cannot be 0 ErrPackedIDZero // ErrOnPublishNil Publisher is nil ErrOnPublishNil // ErrInvalidMessageType Invalid message type ErrInvalidMessageType // ErrInvalidMessageTypeFlags Invalid message flags ErrInvalidMessageTypeFlags // ErrInvalidQoS Invalid message QoS ErrInvalidQoS // ErrInvalidLength Invalid message length ErrInvalidLength // ErrProtocolViolation Message Will violation ErrProtocolViolation // ErrInsufficientBufferSize Insufficient buffer size ErrInsufficientBufferSize // ErrInsufficientDataSize ErrInsufficientDataSize // ErrInvalidTopic Topic is empty ErrInvalidTopic // ErrEmptyPayload Payload is empty ErrEmptyPayload // ErrInvalidReturnCode invalid return code ErrInvalidReturnCode // ErrUnimplemented method not implemented ErrUnimplemented // ErrInvalidLPStringSize LP string size is bigger than expected ErrInvalidLPStringSize // ErrMalformedTopic topic string is not UTF8 ErrMalformedTopic ErrMalformedStream ErrInvalidProtocolVersion ErrNotSet ErrPanicDetected ErrInvalidArgs ErrInvalidUtf8 ErrNotSupported ErrProtocolInvalidName )
nolint: golint
type PingReq ¶
type PingReq struct {
// contains filtered or unexported fields
}
PingReq The PINGREQ Packet is sent from a Client to the Server. It can be used to:
- Indicate to the Server that the Client is alive in the absence of any other Control Packets being sent from the Client to the Server.
- Request that the Server responds to confirm that it is alive.
- Exercise the network to indicate that the Network Connection is active.
func (*PingReq) Desc ¶
func (h *PingReq) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*PingReq) Flags ¶
func (h *PingReq) Flags() byte
Flags returns the fixed header flags for this message.
func (*PingReq) Name ¶
func (h *PingReq) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*PingReq) PropertyForEach ¶
func (h *PingReq) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*PingReq) PropertyGet ¶
func (h *PingReq) PropertyGet(id PropertyID) PropertyToType
func (*PingReq) PropertySet ¶
func (h *PingReq) PropertySet(id PropertyID, val interface{}) error
func (*PingReq) RemainingLength ¶
func (h *PingReq) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*PingReq) SetVersion ¶
func (h *PingReq) SetVersion(v ProtocolVersion)
func (*PingReq) Version ¶
func (h *PingReq) Version() ProtocolVersion
type PingResp ¶
type PingResp struct {
// contains filtered or unexported fields
}
PingResp A PINGRESP Packet is sent by the Server to the Client in response to a PINGREQ Packet. It indicates that the Server is alive.
func (*PingResp) Desc ¶
func (h *PingResp) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*PingResp) Flags ¶
func (h *PingResp) Flags() byte
Flags returns the fixed header flags for this message.
func (*PingResp) Name ¶
func (h *PingResp) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*PingResp) PropertyForEach ¶
func (h *PingResp) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*PingResp) PropertyGet ¶
func (h *PingResp) PropertyGet(id PropertyID) PropertyToType
func (*PingResp) PropertySet ¶
func (h *PingResp) PropertySet(id PropertyID, val interface{}) error
func (*PingResp) RemainingLength ¶
func (h *PingResp) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*PingResp) SetVersion ¶
func (h *PingResp) SetVersion(v ProtocolVersion)
func (*PingResp) Version ¶
func (h *PingResp) Version() ProtocolVersion
type PropertyError ¶
type PropertyError int
PropertyError encodes property error
const ( ErrPropertyNotFound PropertyError = iota ErrPropertyInvalidID ErrPropertyPacketTypeMismatch ErrPropertyTypeMismatch ErrPropertyDuplicate ErrPropertyUnsupported ErrPropertyWrongType )
nolint: golint
type PropertyID ¶
type PropertyID uint32
PropertyID id as per [MQTT-2.2.2]
func (PropertyID) DupAllowed ¶
func (p PropertyID) DupAllowed(t Type) bool
DupAllowed check if property id allows keys duplication
func (PropertyID) IsValid ¶
func (p PropertyID) IsValid() bool
IsValid check if property id is valid spec value
func (PropertyID) IsValidPacketType ¶
func (p PropertyID) IsValidPacketType(t Type) bool
IsValidPacketType check either property id can be used for given packet type
type PropertyToType ¶
type PropertyToType interface { Type() PropertyType AsByte() (byte, error) AsShort() (uint16, error) AsInt() (uint32, error) AsString() (string, error) AsStringPair() (StringPair, error) AsStringPairs() ([]StringPair, error) AsBinary() ([]byte, error) }
PropertyToType represent property value as requested type
type ProtocolVersion ¶
type ProtocolVersion byte
ProtocolVersion describes versions implemented by this package
func (ProtocolVersion) IsValid ¶
func (p ProtocolVersion) IsValid() bool
IsValid check if protocol version is valid for this implementation
type Provider ¶
type Provider interface { // Desc returns a string description of the message type. For example, a // CONNECT message would return "Client request to connect to Server." These // descriptions are statically defined (copied from the MQTT spec) and cannot // be changed. Desc() string // Type returns the MessageType of the Message. The returned value should be one // of the constants defined for MessageType. Type() Type // IDType returns packet id // if has not been set return ErrNotSet ID() (IDType, error) // Encode writes the message bytes into the byte array from the argument. It // returns the number of bytes encoded and whether there's any errors along // the way. If there's any errors, then the byte slice and count should be // considered invalid. Encode([]byte) (int, error) // Size of whole message Size() (int, error) // SetVersion set protocol version used by message SetVersion(v ProtocolVersion) // Version get protocol version used by message Version() ProtocolVersion PropertyGet(PropertyID) PropertyToType PropertySet(PropertyID, interface{}) error PropertyForEach(func(PropertyID, PropertyToType)) error // contains filtered or unexported methods }
Provider is an interface defined for all MQTT message types.
type Publish ¶
type Publish struct {
// contains filtered or unexported fields
}
Publish A PUBLISH Control Packet is sent from a Client to a Server or from Server to a Client to transport an Application Message.
func (*Publish) Clone ¶
func (msg *Publish) Clone(v ProtocolVersion) (*Publish, error)
Clone packet qos, topic, payload, retain and properties
func (*Publish) Desc ¶
func (h *Publish) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*Publish) Dup ¶
Dup returns the value specifying the duplicate delivery of a PUBLISH Control Packet. If the DUP flag is set to 0, it indicates that this is the first occasion that the Client or Server has attempted to send this MQTT PUBLISH Packet. If the DUP flag is set to 1, it indicates that this might be re-delivery of an earlier attempt to send the Packet.
func (*Publish) Expired ¶
Expired check if packet has elapsed it's time or not if not expirable returns false
func (*Publish) Flags ¶
func (h *Publish) Flags() byte
Flags returns the fixed header flags for this message.
func (*Publish) Name ¶
func (h *Publish) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*Publish) Payload ¶
Payload returns the application message that's part of the PUBLISH message.
func (*Publish) PropertyForEach ¶
func (h *Publish) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*Publish) PropertyGet ¶
func (h *Publish) PropertyGet(id PropertyID) PropertyToType
func (*Publish) PropertySet ¶
func (h *Publish) PropertySet(id PropertyID, val interface{}) error
func (*Publish) QoS ¶
QoS returns the field that indicates the level of assurance for delivery of an Application Message. The values are QoS0, QoS1 and QoS2.
func (*Publish) RemainingLength ¶
func (h *Publish) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*Publish) Retain ¶
Retain returns the value of the RETAIN flag. This flag is only used on the PUBLISH Packet. If the RETAIN flag is set to 1, in a PUBLISH Packet sent by a Client to a Server, the Server MUST store the Application Message and its QoS, so that it can be delivered to future subscribers whose subscriptions match its topic name.
func (*Publish) SetDup ¶
SetDup sets the value specifying the duplicate delivery of a PUBLISH Control Packet.
func (*Publish) SetPacketID ¶
SetPacketID sets the ID of the packet.
func (*Publish) SetPayload ¶
SetPayload sets the application message that's part of the PUBLISH message.
func (*Publish) SetPublishID ¶
SetPublishID internally used publish id to allow No Local option
func (*Publish) SetQoS ¶
SetQoS sets the field that indicates the level of assurance for delivery of an Application Message. The values are QoS0, QoS1 and QoS2. An error is returned if the value is not one of these.
func (*Publish) SetTopic ¶
SetTopic sets the the topic name that identifies the information channel to which payload data is published. An error is returned if ValidTopic() is falbase.
func (*Publish) SetVersion ¶
func (h *Publish) SetVersion(v ProtocolVersion)
func (*Publish) Topic ¶
Topic returns the the topic name that identifies the information channel to which payload data is published.
func (*Publish) Version ¶
func (h *Publish) Version() ProtocolVersion
type QosType ¶
type QosType byte
QosType QoS type
const ( // QoS0 At most once delivery // The message is delivered according to the capabilities of the underlying network. // No response is sent by the receiver and no retry is performed by the sender. The // message arrives at the receiver either once or not at all. QoS0 QosType = iota // QoS1 At least once delivery // This quality of service ensures that the message arrives at the receiver at least once. // A QoS 1 PUBLISH Packet has a Packet Identifier in its variable header and is acknowledged // by a PUBACK Packet. Section 2.3.1 provides more information about Packet Identifiers. QoS1 // QoS2 Exactly once delivery // This is the highest quality of service, for use when neither loss nor duplication of // messages are acceptable. There is an increased overhead associated with this quality of // service. QoS2 // QosFailure is a return value for a subscription if there's a problem while subscribing // to a specific topic. QosFailure = 0x80 )
func (QosType) IsValid ¶
IsValid checks the QoS value to see if it's valid. Valid QoS are QoS0, QoS1, and QoS2.
func (QosType) IsValidFull ¶
IsValidFull checks the QoS value to see if it's valid. Valid QoS are QoS0, QoS1, QoS2 and QosFailure.
type ReasonCode ¶
type ReasonCode byte
ReasonCode contains return codes across all MQTT specs
const ( CodeSuccess ReasonCode = 0x00 // | \ | CodeRefusedUnacceptableProtocolVersion ReasonCode = 0x01 // | \ | CodeRefusedIdentifierRejected ReasonCode = 0x02 // | \ | CodeRefusedBadUsernameOrPassword ReasonCode = 0x04 // | \ | CodeRefusedNotAuthorized ReasonCode = 0x05 // <--| \ | //CodeDisconnectWithWillMessage ReasonCode = 0x04 // \ | CodeNoMatchingSubscribers ReasonCode = 0x10 // \ | CodeNoSubscriptionExisted ReasonCode = 0x11 // \ | CodeContinueAuthentication ReasonCode = 0x18 // \ | CodeReAuthenticate ReasonCode = 0x19 // \ | CodeUnspecifiedError ReasonCode = 0x80 // \ | CodeMalformedPacket ReasonCode = 0x81 // \ | CodeProtocolError ReasonCode = 0x82 // \ | CodeImplementationSpecificError ReasonCode = 0x83 // \ | CodeUnsupportedProtocol ReasonCode = 0x84 // \ | CodeInvalidClientID ReasonCode = 0x85 // \ | CodeBadUserOrPassword ReasonCode = 0x86 // \ | CodeNotAuthorized ReasonCode = 0x87 // \ | CodeServerBusy ReasonCode = 0x89 // \ | CodeBanned ReasonCode = 0x8A // \ | CodeServerShuttingDown ReasonCode = 0x8B // \ | CodeBadAuthMethod ReasonCode = 0x8C // \ | CodeKeepAliveTimeout ReasonCode = 0x8D // \ | CodeSessionTakenOver ReasonCode = 0x8E // \ | CodeInvalidTopicFilter ReasonCode = 0x8F // \ | CodeInvalidTopicName ReasonCode = 0x90 // \ | CodePacketIDInUse ReasonCode = 0x91 // \ | CodePacketIDNotFound ReasonCode = 0x92 // \ | CodeReceiveMaximumExceeded ReasonCode = 0x93 // \ | CodeInvalidTopicAlias ReasonCode = 0x94 // \ | CodePacketTooLarge ReasonCode = 0x95 // \ | CodeMessageRateTooHigh ReasonCode = 0x96 // \ | CodeQuotaExceeded ReasonCode = 0x97 // \ | CodeAdministrativeAction ReasonCode = 0x98 // \ | CodeInvalidPayloadFormat ReasonCode = 0x99 // \ | CodeRetainNotSupported ReasonCode = 0x9A // \ | CodeNotSupportedQoS ReasonCode = 0x9B // \ | CodeUseAnotherServer ReasonCode = 0x9C // \ | CodeServerMoved ReasonCode = 0x9D // \ | CodeConnectionRateExceeded ReasonCode = 0x9F // \ | CodeMaximumConnectTime ReasonCode = 0xA0 // \ | CodeSubscriptionIDNotSupported ReasonCode = 0xA1 // \ | CodeWildcardSubscriptionsNotSupported ReasonCode = 0xA2 // \ <--| )
nolint: golint // V3.1.1 \ V5.0
func (ReasonCode) Error ¶
func (c ReasonCode) Error() string
Error returns the description of the ReturnCode
func (ReasonCode) IsValid ¶
func (c ReasonCode) IsValid() bool
IsValid check either reason code is valid across all MQTT specs
func (ReasonCode) IsValidForType ¶
func (c ReasonCode) IsValidForType(p Type) bool
IsValidForType check either reason code is valid for giver packet type
func (ReasonCode) IsValidV3 ¶
func (c ReasonCode) IsValidV3() bool
IsValidV3 check either reason code is valid for MQTT V3.1/V3.1.1 or not
func (ReasonCode) IsValidV5 ¶
func (c ReasonCode) IsValidV5() bool
IsValidV5 check either reason code is valid for MQTT V5.0 or not
func (ReasonCode) PacketTypeDir ¶
func (c ReasonCode) PacketTypeDir(p Type) (CodeIssuer, error)
PacketTypeDir check direction of packet type
type RetainHandling ¶
type RetainHandling uint8
RetainHandling describe how retained messages are handled during subscribe
const ( // RetainHandlingRetain publish retained messages on subscribe RetainHandlingRetain RetainHandling = iota // RetainHandlingIfNotExists publish retained messages on subscribe only when it's new subscription to given topic RetainHandlingIfNotExists // RetainHandlingDoNotRetain do not publish retained messages on subscribe RetainHandlingDoNotRetain )
type SubAck ¶
type SubAck struct {
// contains filtered or unexported fields
}
SubAck A SUBACK Packet is sent by the Server to the Client to confirm receipt and processing of a SUBSCRIBE Packet.
A SUBACK Packet contains a list of return codes, that specify the maximum QoS level that was granted in each Subscription that was requested by the SUBSCRIBE.
func (*SubAck) AddReturnCode ¶
func (msg *SubAck) AddReturnCode(ret ReasonCode) error
AddReturnCode adds a single QoS return value.
func (*SubAck) AddReturnCodes ¶
func (msg *SubAck) AddReturnCodes(ret []ReasonCode) error
AddReturnCodes sets the list of QoS returns from the subscriptions sent in the SUBSCRIBE message. An error is returned if any of the QoS values are not valid.
func (*SubAck) Desc ¶
func (h *SubAck) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*SubAck) Flags ¶
func (h *SubAck) Flags() byte
Flags returns the fixed header flags for this message.
func (*SubAck) Name ¶
func (h *SubAck) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*SubAck) PropertyForEach ¶
func (h *SubAck) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*SubAck) PropertyGet ¶
func (h *SubAck) PropertyGet(id PropertyID) PropertyToType
func (*SubAck) PropertySet ¶
func (h *SubAck) PropertySet(id PropertyID, val interface{}) error
func (*SubAck) RemainingLength ¶
func (h *SubAck) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*SubAck) ReturnCodes ¶
func (msg *SubAck) ReturnCodes() []ReasonCode
ReturnCodes returns the list of QoS returns from the subscriptions sent in the SUBSCRIBE message.
func (*SubAck) SetPacketID ¶
SetPacketID sets the ID of the packet.
func (*SubAck) SetVersion ¶
func (h *SubAck) SetVersion(v ProtocolVersion)
func (*SubAck) Version ¶
func (h *SubAck) Version() ProtocolVersion
type Subscribe ¶
type Subscribe struct {
// contains filtered or unexported fields
}
Subscribe The SUBSCRIBE Packet is sent from the Client to the Server to create one or more Subscriptions. Each Subscription registers a Client’s interest in one or more Topics. The Server sends PUBLISH Packets to the Client in order to forward Application Messages that were published to Topics that match these Subscriptions. The SUBSCRIBE Packet also specifies (for each Subscription) the maximum QoS with which the Server can send Application Messages to the Client.
func (*Subscribe) AddTopic ¶
func (msg *Subscribe) AddTopic(topic string, ops SubscriptionOptions) error
AddTopic adds a single topic to the message, along with the corresponding QoS. An error is returned if QoS is invalid.
func (*Subscribe) Desc ¶
func (h *Subscribe) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*Subscribe) Flags ¶
func (h *Subscribe) Flags() byte
Flags returns the fixed header flags for this message.
func (*Subscribe) Name ¶
func (h *Subscribe) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*Subscribe) PropertyForEach ¶
func (h *Subscribe) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*Subscribe) PropertyGet ¶
func (h *Subscribe) PropertyGet(id PropertyID) PropertyToType
func (*Subscribe) PropertySet ¶
func (h *Subscribe) PropertySet(id PropertyID, val interface{}) error
func (*Subscribe) RemainingLength ¶
func (h *Subscribe) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*Subscribe) RemoveTopic ¶
RemoveTopic removes a single topic from the list of existing ones in the message. If topic does not exist it just does nothing.
func (*Subscribe) SetPacketID ¶
SetPacketID sets the ID of the packet.
func (*Subscribe) SetVersion ¶
func (h *Subscribe) SetVersion(v ProtocolVersion)
func (*Subscribe) Type ¶
func (h *Subscribe) Type() Type
Type returns the MessageType of the Message
func (*Subscribe) Version ¶
func (h *Subscribe) Version() ProtocolVersion
type SubscriptionOptions ¶
type SubscriptionOptions byte
SubscriptionOptions as per [MQTT-3.8.3.1]
func (SubscriptionOptions) NL ¶
func (s SubscriptionOptions) NL() bool
NL No Local option
if true Application Messages MUST NOT be forwarded to a connection with a ClientID equal to the ClientID of the publishing connection
V5.0 ONLY
func (SubscriptionOptions) RAP ¶
func (s SubscriptionOptions) RAP() bool
RAP Retain As Published option
true: Application Messages forwarded using this subscription keep the RETAIN flag they were published with false : Application Messages forwarded using this subscription have the RETAIN flag set to 0.
Retained messages sent when the subscription is established have the RETAIN flag set to 1. V5.0 ONLY
func (SubscriptionOptions) RetainHandling ¶
func (s SubscriptionOptions) RetainHandling() RetainHandling
RetainHandling specifies whether retained messages are sent when the subscription is established. This does not affect the sending of retained messages at any point after the subscribe. If there are no retained messages matching the Topic Filter, all of these values act the same. The values are:
0 = Send retained messages at the time of the subscribe 1 = Send retained messages at subscribe only if the subscription does not currently exist 2 = Do not send retained messages at the time of the subscribe
V5.0 ONLY
type TopicQos ¶
type TopicQos map[string]SubscriptionOptions
TopicQos map containing topics as a keys with respective subscription options as value
type Type ¶
type Type byte
Type is the type representing the MQTT packet types. In the MQTT spec, MQTT control packet type is represented as a 4-bit unsigned value.
const ( // RESERVED is a reserved value and should be considered an invalid message type RESERVED Type = iota // CONNECT Client request to connect to Server // version: v3.1, v3.1.1, v5.0 // Dir: Client to Server CONNECT // CONNACK Connect acknowledgement // version: v3.1, v3.1.1, v5.0 // Dir: Server to Client CONNACK // PUBLISH Client to Server, or Server to Client. Publish message. PUBLISH // PUBACK Client to Server, or Server to Client. Publish acknowledgment for // QoS 1 messages. PUBACK // PUBREC Client to Server, or Server to Client. Publish received for QoS 2 messages. // Assured delivery part 1. PUBREC // PUBREL Client to Server, or Server to Client. Publish release for QoS 2 messages. // Assured delivery part 1. PUBREL // PUBCOMP Client to Server, or Server to Client. Publish complete for QoS 2 messages. // Assured delivery part 3. PUBCOMP // SUBSCRIBE Client to Server. Client subscribe request. SUBSCRIBE // SUBACK Server to Client. Subscribe acknowledgement. SUBACK // UNSUBSCRIBE Client to Server. Unsubscribe request. UNSUBSCRIBE // UNSUBACK Server to Client. Unsubscribe acknowlegment. UNSUBACK // PINGREQ Client to Server. PING request. PINGREQ // PINGRESP Server to Client. PING response. PINGRESP // DISCONNECT Client to Server. Client is disconnecting. DISCONNECT // AUTH is a reserved value and should be considered an invalid message type. AUTH )
func (Type) DefaultFlags ¶
DefaultFlags returns the default flag values for the message type, as defined by the MQTT spec.
func (Type) Desc ¶
Desc returns the description of the message type. It is statically defined (copied from MQTT spec) and cannot be changed.
type UnSubAck ¶
type UnSubAck struct {
// contains filtered or unexported fields
}
UnSubAck The UNSUBACK Packet is sent by the Server to the Client to confirm receipt of an UNSUBSCRIBE Packet.
func (*UnSubAck) AddReturnCode ¶
func (msg *UnSubAck) AddReturnCode(ret ReasonCode) error
AddReturnCode adds a single QoS return value.
func (*UnSubAck) AddReturnCodes ¶
func (msg *UnSubAck) AddReturnCodes(ret []ReasonCode) error
AddReturnCodes sets the list of QoS returns from the subscriptions sent in the SUBSCRIBE message. An error is returned if any of the QoS values are not valid.
func (*UnSubAck) Desc ¶
func (h *UnSubAck) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*UnSubAck) Flags ¶
func (h *UnSubAck) Flags() byte
Flags returns the fixed header flags for this message.
func (*UnSubAck) Name ¶
func (h *UnSubAck) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*UnSubAck) PropertyForEach ¶
func (h *UnSubAck) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*UnSubAck) PropertyGet ¶
func (h *UnSubAck) PropertyGet(id PropertyID) PropertyToType
func (*UnSubAck) PropertySet ¶
func (h *UnSubAck) PropertySet(id PropertyID, val interface{}) error
func (*UnSubAck) RemainingLength ¶
func (h *UnSubAck) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*UnSubAck) ReturnCodes ¶
func (msg *UnSubAck) ReturnCodes() []ReasonCode
ReturnCodes returns the list of QoS returns from the subscriptions sent in the SUBSCRIBE message.
func (*UnSubAck) SetPacketID ¶
SetPacketID sets the ID of the packet.
func (*UnSubAck) SetVersion ¶
func (h *UnSubAck) SetVersion(v ProtocolVersion)
func (*UnSubAck) Version ¶
func (h *UnSubAck) Version() ProtocolVersion
type UnSubscribe ¶
type UnSubscribe struct {
// contains filtered or unexported fields
}
UnSubscribe An UNSUBSCRIBE Packet is sent by the Client to the Server, to unsubscribe from topics.
func (*UnSubscribe) AddTopic ¶
func (msg *UnSubscribe) AddTopic(topic string) error
AddTopic adds a single topic to the message.
func (*UnSubscribe) Desc ¶
func (h *UnSubscribe) Desc() string
Desc returns a string description of the message type. For example, a CONNECT message would return "Client request to connect to Server." These descriptions are statically defined (copied from the MQTT spec) and cannot be changed.
func (*UnSubscribe) Flags ¶
func (h *UnSubscribe) Flags() byte
Flags returns the fixed header flags for this message.
func (*UnSubscribe) Name ¶
func (h *UnSubscribe) Name() string
Name returns a string representation of the message type. Examples include "PUBLISH", "SUBSCRIBE", and others. This is statically defined for each of the message types and cannot be changed.
func (*UnSubscribe) PropertyForEach ¶
func (h *UnSubscribe) PropertyForEach(f func(PropertyID, PropertyToType)) error
func (*UnSubscribe) PropertyGet ¶
func (h *UnSubscribe) PropertyGet(id PropertyID) PropertyToType
func (*UnSubscribe) PropertySet ¶
func (h *UnSubscribe) PropertySet(id PropertyID, val interface{}) error
func (*UnSubscribe) RemainingLength ¶
func (h *UnSubscribe) RemainingLength() int32
RemainingLength returns the length of the non-fixed-header part of the message.
func (*UnSubscribe) RemoveTopic ¶
func (msg *UnSubscribe) RemoveTopic(topic string)
RemoveTopic removes a single topic from the list of existing ones in the message. If topic does not exist it just does nothing.
func (*UnSubscribe) SetPacketID ¶
func (msg *UnSubscribe) SetPacketID(v IDType)
SetPacketID sets the ID of the packet.
func (*UnSubscribe) SetVersion ¶
func (h *UnSubscribe) SetVersion(v ProtocolVersion)
func (*UnSubscribe) Topics ¶
func (msg *UnSubscribe) Topics() omap.Map
Topics returns a list of topics sent by the Client.
func (*UnSubscribe) Type ¶
func (h *UnSubscribe) Type() Type
Type returns the MessageType of the Message
func (*UnSubscribe) Version ¶
func (h *UnSubscribe) Version() ProtocolVersion