message

package
Version: v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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)
	PropertySharedSubscriptionAvailable     = PropertyID(0x2A)
)

nolint: golint

View Source
const (
	PropertyTypeByte = iota
	PropertyTypeShort
	PropertyTypeInt
	PropertyTypeVarInt
	PropertyTypeString
	PropertyTypeStringPair
	PropertyTypeBinary
)

nolint: golint

View Source
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)
)
View Source
const (
	// MaxLPString maximum size of length-prefixed string
	MaxLPString = 65535
)

Variables

View Source
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

func ReadLPBytes(buf []byte) ([]byte, int, error)

ReadLPBytes read length prefixed bytes

func ValidTopic

func ValidTopic(topic string) bool

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 #.

func WriteLPBytes

func WriteLPBytes(buf []byte, b []byte) (int, error)

WriteLPBytes write length prefixed bytes

func WriteToBuffer

func WriteToBuffer(msg Provider, to *buffer.Type) (int, error)

WriteToBuffer encode and send message into ring buffer

Types

type AckMessage

type AckMessage struct {
	// contains filtered or unexported fields
}

AckMessage 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 (*AckMessage) Desc

func (h *AckMessage) 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 (*AckMessage) Encode

func (h *AckMessage) Encode(dst []byte) (int, error)

func (*AckMessage) Flags

func (h *AckMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*AckMessage) Name

func (h *AckMessage) 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 (*AckMessage) PacketID

func (h *AckMessage) PacketID() (PacketID, error)

func (*AckMessage) PropertyForEach

func (h *AckMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*AckMessage) PropertyGet

func (h *AckMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*AckMessage) PropertySet

func (h *AckMessage) PropertySet(id PropertyID, val interface{}) error

func (*AckMessage) Reason

func (msg *AckMessage) Reason() ReasonCode

Reason return acknowledgment reason

func (*AckMessage) RemainingLength

func (h *AckMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*AckMessage) SetPacketID

func (msg *AckMessage) SetPacketID(v PacketID)

SetPacketID sets the ID of the packet.

func (*AckMessage) SetReason

func (msg *AckMessage) SetReason(c ReasonCode)

SetReason of acknowledgment

func (*AckMessage) SetVersion

func (h *AckMessage) SetVersion(v ProtocolVersion)

func (*AckMessage) Size

func (h *AckMessage) Size() (int, error)

Size of message

func (*AckMessage) Type

func (h *AckMessage) Type() PacketType

Type returns the MessageType of the Message

func (*AckMessage) Version

func (h *AckMessage) Version() ProtocolVersion

type AuthMessage

type AuthMessage struct {
	// contains filtered or unexported fields
}

AuthMessage 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 (*AuthMessage) Desc

func (h *AuthMessage) 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 (*AuthMessage) Encode

func (h *AuthMessage) Encode(dst []byte) (int, error)

func (*AuthMessage) Flags

func (h *AuthMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*AuthMessage) Name

func (h *AuthMessage) 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 (*AuthMessage) PacketID

func (h *AuthMessage) PacketID() (PacketID, error)

func (*AuthMessage) PropertyForEach

func (h *AuthMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*AuthMessage) PropertyGet

func (h *AuthMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*AuthMessage) PropertySet

func (h *AuthMessage) PropertySet(id PropertyID, val interface{}) error

func (*AuthMessage) ReasonCode

func (msg *AuthMessage) ReasonCode() ReasonCode

ReasonCode get authentication reason

func (*AuthMessage) RemainingLength

func (h *AuthMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*AuthMessage) SetReasonCode

func (msg *AuthMessage) SetReasonCode(c ReasonCode) error

SetReasonCode set authentication reason code

func (*AuthMessage) SetVersion

func (h *AuthMessage) SetVersion(v ProtocolVersion)

func (*AuthMessage) Size

func (h *AuthMessage) Size() (int, error)

Size of message

func (*AuthMessage) Type

func (h *AuthMessage) Type() PacketType

Type returns the MessageType of the Message

func (*AuthMessage) Version

func (h *AuthMessage) Version() ProtocolVersion

type CodeIssuer

type CodeIssuer byte

CodeIssuer who is message issuer

const (
	CodeIssuerServer CodeIssuer = 0x00
	CodeIssuerClient
	CodeIssuerBoth
	CodeIssuerInvalid
)

nolint: golint

type ConnAckMessage

type ConnAckMessage struct {
	// contains filtered or unexported fields
}

ConnAckMessage 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 (*ConnAckMessage) Desc

func (h *ConnAckMessage) 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 (*ConnAckMessage) Encode

func (h *ConnAckMessage) Encode(dst []byte) (int, error)

func (*ConnAckMessage) Flags

func (h *ConnAckMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*ConnAckMessage) Name

func (h *ConnAckMessage) 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 (*ConnAckMessage) PacketID

func (h *ConnAckMessage) PacketID() (PacketID, error)

func (*ConnAckMessage) PropertyForEach

func (h *ConnAckMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*ConnAckMessage) PropertyGet

func (h *ConnAckMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*ConnAckMessage) PropertySet

func (h *ConnAckMessage) PropertySet(id PropertyID, val interface{}) error

func (*ConnAckMessage) RemainingLength

func (h *ConnAckMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*ConnAckMessage) ReturnCode

func (msg *ConnAckMessage) ReturnCode() ReasonCode

ReturnCode returns the return code received for the CONNECT message. The return type is an error

func (*ConnAckMessage) SessionPresent

func (msg *ConnAckMessage) SessionPresent() bool

SessionPresent returns the session present flag value

func (*ConnAckMessage) SetReturnCode

func (msg *ConnAckMessage) SetReturnCode(ret ReasonCode) error

SetReturnCode of conn

func (*ConnAckMessage) SetSessionPresent

func (msg *ConnAckMessage) SetSessionPresent(v bool)

SetSessionPresent sets the value of the session present flag

func (*ConnAckMessage) SetVersion

func (h *ConnAckMessage) SetVersion(v ProtocolVersion)

func (*ConnAckMessage) Size

func (h *ConnAckMessage) Size() (int, error)

Size of message

func (*ConnAckMessage) Type

func (h *ConnAckMessage) Type() PacketType

Type returns the MessageType of the Message

func (*ConnAckMessage) Version

func (h *ConnAckMessage) Version() ProtocolVersion

type ConnectMessage

type ConnectMessage struct {
	// contains filtered or unexported fields
}

ConnectMessage 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 (*ConnectMessage) CleanStart

func (msg *ConnectMessage) CleanStart() bool

CleanStart 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 (*ConnectMessage) ClientID

func (msg *ConnectMessage) ClientID() []byte

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 (*ConnectMessage) Credentials

func (msg *ConnectMessage) Credentials() ([]byte, []byte)

Credentials returns user and password

func (*ConnectMessage) Desc

func (h *ConnectMessage) 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 (*ConnectMessage) Encode

func (h *ConnectMessage) Encode(dst []byte) (int, error)

func (*ConnectMessage) Flags

func (h *ConnectMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*ConnectMessage) KeepAlive

func (msg *ConnectMessage) KeepAlive() uint16

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 (*ConnectMessage) Name

func (h *ConnectMessage) 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 (*ConnectMessage) PacketID

func (h *ConnectMessage) PacketID() (PacketID, error)

func (*ConnectMessage) PropertyForEach

func (h *ConnectMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*ConnectMessage) PropertyGet

func (h *ConnectMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*ConnectMessage) PropertySet

func (h *ConnectMessage) PropertySet(id PropertyID, val interface{}) error

func (*ConnectMessage) RemainingLength

func (h *ConnectMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*ConnectMessage) ResetWill

func (msg *ConnectMessage) ResetWill()

ResetWill reset will state of message

func (*ConnectMessage) SetCleanStart

func (msg *ConnectMessage) SetCleanStart(v bool)

SetCleanStart sets the bit that specifies the handling of the Session state.

func (*ConnectMessage) SetClientID

func (msg *ConnectMessage) SetClientID(v []byte) error

SetClientID sets an ID that identifies the Client to the Server.

func (*ConnectMessage) SetCredentials

func (msg *ConnectMessage) SetCredentials(u []byte, p []byte) error

SetCredentials set username and password

func (*ConnectMessage) SetKeepAlive

func (msg *ConnectMessage) SetKeepAlive(v uint16)

SetKeepAlive sets the time interval in which the server should keep the connection alive.

func (*ConnectMessage) SetVersion

func (h *ConnectMessage) SetVersion(v ProtocolVersion)

func (*ConnectMessage) SetWill

func (msg *ConnectMessage) SetWill(t string, m []byte, qos QosType, retain bool) error

SetWill state of message

func (*ConnectMessage) Size

func (h *ConnectMessage) Size() (int, error)

Size of message

func (*ConnectMessage) Type

func (h *ConnectMessage) Type() PacketType

Type returns the MessageType of the Message

func (*ConnectMessage) Version

func (h *ConnectMessage) Version() ProtocolVersion

func (*ConnectMessage) Will

func (msg *ConnectMessage) Will() (string, []byte, QosType, bool, bool)

Will returns the topic in which the Will Message should be published to. If the Will Flag is set to 1, the Will Topic must be in the payload. returns will topic, will message, will qos , will retain, will if last param is false will is not set

type DisconnectMessage

type DisconnectMessage struct {
	// contains filtered or unexported fields
}

DisconnectMessage The DISCONNECT Packet is the final Control Packet sent from the Client to the Server. It indicates that the Client is disconnecting cleanly.

func (*DisconnectMessage) Desc

func (h *DisconnectMessage) 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 (*DisconnectMessage) Encode

func (h *DisconnectMessage) Encode(dst []byte) (int, error)

func (*DisconnectMessage) Flags

func (h *DisconnectMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*DisconnectMessage) Name

func (h *DisconnectMessage) 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 (*DisconnectMessage) PacketID

func (h *DisconnectMessage) PacketID() (PacketID, error)

func (*DisconnectMessage) PropertyForEach

func (h *DisconnectMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*DisconnectMessage) PropertyGet

func (h *DisconnectMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*DisconnectMessage) PropertySet

func (h *DisconnectMessage) PropertySet(id PropertyID, val interface{}) error

func (*DisconnectMessage) ReasonCode

func (msg *DisconnectMessage) ReasonCode() ReasonCode

ReasonCode get disconnect reason

func (*DisconnectMessage) RemainingLength

func (h *DisconnectMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*DisconnectMessage) SetReasonCode

func (msg *DisconnectMessage) SetReasonCode(c ReasonCode)

SetReasonCode set disconnect reason

func (*DisconnectMessage) SetVersion

func (h *DisconnectMessage) SetVersion(v ProtocolVersion)

func (*DisconnectMessage) Size

func (h *DisconnectMessage) Size() (int, error)

Size of message

func (*DisconnectMessage) Type

func (h *DisconnectMessage) Type() PacketType

Type returns the MessageType of the Message

func (*DisconnectMessage) Version

func (h *DisconnectMessage) 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

func (Error) Error

func (e Error) Error() string

Error returns the corresponding error string for the ConnAckCode

type KVPair

type KVPair struct {
	Key   string
	Value string
}

KVPair user defined properties

type PacketID

type PacketID uint16

PacketID as per [MQTT-2.2.1]

type PacketType

type PacketType byte

PacketType 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 PacketType = 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 (PacketType) DefaultFlags

func (t PacketType) DefaultFlags() byte

DefaultFlags returns the default flag values for the message type, as defined by the MQTT spec.

func (PacketType) Desc

func (t PacketType) Desc() string

Desc returns the description of the message type. It is statically defined (copied from MQTT spec) and cannot be changed.

func (PacketType) Name

func (t PacketType) Name() string

Name returns the name of the message type. It should correspond to one of the constant values defined for MessageType. It is statically defined and cannot be changed.

func (PacketType) Valid

func (t PacketType) Valid(v ProtocolVersion) (bool, error)

Valid returns a boolean indicating whether the message type is valid or not.

type PingReqMessage

type PingReqMessage struct {
	// contains filtered or unexported fields
}

PingReqMessage The PINGREQ Packet is sent from a Client to the Server. It can be used to:

  1. 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.
  2. Request that the Server responds to confirm that it is alive.
  3. Exercise the network to indicate that the Network Connection is active.

func (*PingReqMessage) Desc

func (h *PingReqMessage) 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 (*PingReqMessage) Encode

func (h *PingReqMessage) Encode(dst []byte) (int, error)

func (*PingReqMessage) Flags

func (h *PingReqMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*PingReqMessage) Name

func (h *PingReqMessage) 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 (*PingReqMessage) PacketID

func (h *PingReqMessage) PacketID() (PacketID, error)

func (*PingReqMessage) PropertyForEach

func (h *PingReqMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*PingReqMessage) PropertyGet

func (h *PingReqMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*PingReqMessage) PropertySet

func (h *PingReqMessage) PropertySet(id PropertyID, val interface{}) error

func (*PingReqMessage) RemainingLength

func (h *PingReqMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*PingReqMessage) SetVersion

func (h *PingReqMessage) SetVersion(v ProtocolVersion)

func (*PingReqMessage) Size

func (h *PingReqMessage) Size() (int, error)

Size of message

func (*PingReqMessage) Type

func (h *PingReqMessage) Type() PacketType

Type returns the MessageType of the Message

func (*PingReqMessage) Version

func (h *PingReqMessage) Version() ProtocolVersion

type PingRespMessage

type PingRespMessage struct {
	// contains filtered or unexported fields
}

PingRespMessage 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 (*PingRespMessage) Desc

func (h *PingRespMessage) 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 (*PingRespMessage) Encode

func (h *PingRespMessage) Encode(dst []byte) (int, error)

func (*PingRespMessage) Flags

func (h *PingRespMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*PingRespMessage) Name

func (h *PingRespMessage) 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 (*PingRespMessage) PacketID

func (h *PingRespMessage) PacketID() (PacketID, error)

func (*PingRespMessage) PropertyForEach

func (h *PingRespMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*PingRespMessage) PropertyGet

func (h *PingRespMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*PingRespMessage) PropertySet

func (h *PingRespMessage) PropertySet(id PropertyID, val interface{}) error

func (*PingRespMessage) RemainingLength

func (h *PingRespMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*PingRespMessage) SetVersion

func (h *PingRespMessage) SetVersion(v ProtocolVersion)

func (*PingRespMessage) Size

func (h *PingRespMessage) Size() (int, error)

Size of message

func (*PingRespMessage) Type

func (h *PingRespMessage) Type() PacketType

Type returns the MessageType of the Message

func (*PingRespMessage) Version

func (h *PingRespMessage) Version() ProtocolVersion

type PropertyError

type PropertyError int

PropertyError encodes property error

const (
	ErrPropertyNotFound PropertyError = iota
	ErrPropertyInvalidID
	ErrPropertyPacketTypeMismatch
	ErrPropertyTypeMismatch
	ErrPropertyDuplicate
	ErrPropertyUnsupported
)

nolint: golint

func (PropertyError) Error

func (e PropertyError) Error() string

Error

type PropertyID

type PropertyID uint32

PropertyID id as per [MQTT-2.2.2]

func (PropertyID) DupAllowed

func (p PropertyID) DupAllowed() 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 PacketType) bool

IsValidPacketType check either property id can be used for given packet type

type PropertyType

type PropertyType byte

PropertyType value type used be property ID

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() PacketType

	// PacketID returns packet id
	// if has not been set return ErrNotSet
	PacketID() (PacketID, 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) (interface{}, error)

	PropertySet(PropertyID, interface{}) error

	PropertyForEach(func(PropertyID, interface{})) error
	// contains filtered or unexported methods
}

Provider is an interface defined for all MQTT message types.

func Decode

func Decode(v ProtocolVersion, buf []byte) (msg Provider, total int, err error)

Decode buf into message and return Provider type

func NewMessage

func NewMessage(v ProtocolVersion, t PacketType) (Provider, error)

NewMessage creates a new message based on the message type. It is a shortcut to call one of the New*Message functions. If an error is returned then the message type is invalid.

type PublishMessage

type PublishMessage struct {
	// contains filtered or unexported fields
}

PublishMessage A PUBLISH Control Packet is sent from a Client to a Server or from Server to a Client to transport an Application Message.

func (*PublishMessage) Desc

func (h *PublishMessage) 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 (*PublishMessage) Dup

func (msg *PublishMessage) Dup() bool

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 (*PublishMessage) Encode

func (h *PublishMessage) Encode(dst []byte) (int, error)

func (*PublishMessage) Flags

func (h *PublishMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*PublishMessage) Name

func (h *PublishMessage) 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 (*PublishMessage) PacketID

func (h *PublishMessage) PacketID() (PacketID, error)

func (*PublishMessage) Payload

func (msg *PublishMessage) Payload() []byte

Payload returns the application message that's part of the PUBLISH message.

func (*PublishMessage) PropertyForEach

func (h *PublishMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*PublishMessage) PropertyGet

func (h *PublishMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*PublishMessage) PropertySet

func (h *PublishMessage) PropertySet(id PropertyID, val interface{}) error

func (*PublishMessage) QoS

func (msg *PublishMessage) QoS() QosType

QoS returns the field that indicates the level of assurance for delivery of an Application Message. The values are QoS0, QoS1 and QoS2.

func (*PublishMessage) RemainingLength

func (h *PublishMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*PublishMessage) Retain

func (msg *PublishMessage) Retain() bool

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 (*PublishMessage) SetDup

func (msg *PublishMessage) SetDup(v bool)

SetDup sets the value specifying the duplicate delivery of a PUBLISH Control Packet.

func (*PublishMessage) SetPacketID

func (msg *PublishMessage) SetPacketID(v PacketID)

SetPacketID sets the ID of the packet.

func (*PublishMessage) SetPayload

func (msg *PublishMessage) SetPayload(v []byte)

SetPayload sets the application message that's part of the PUBLISH message.

func (*PublishMessage) SetQoS

func (msg *PublishMessage) SetQoS(v QosType) error

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 (*PublishMessage) SetRetain

func (msg *PublishMessage) SetRetain(v bool)

SetRetain sets the value of the RETAIN flag.

func (*PublishMessage) SetTopic

func (msg *PublishMessage) SetTopic(v string) error

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 (*PublishMessage) SetVersion

func (h *PublishMessage) SetVersion(v ProtocolVersion)

func (*PublishMessage) Size

func (h *PublishMessage) Size() (int, error)

Size of message

func (*PublishMessage) Topic

func (msg *PublishMessage) Topic() string

Topic returns the the topic name that identifies the information channel to which payload data is published.

func (*PublishMessage) Type

func (h *PublishMessage) Type() PacketType

Type returns the MessageType of the Message

func (*PublishMessage) Version

func (h *PublishMessage) 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

func (c QosType) IsValid() bool

IsValid checks the QoS value to see if it's valid. Valid QoS are QoS0, QoS1, and QoS2.

func (QosType) IsValidFull

func (c QosType) IsValidFull() bool

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 //    |   \    |
	CodeRefusedServerUnavailable           ReasonCode = 0x03 //    |   \    |
	CodeRefusedBadUsernameOrPassword       ReasonCode = 0x04 //    |   \    |
	CodeRefusedNotAuthorized               ReasonCode = 0x05 // <--|   \    |
	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 //        \    |
	CodeServerUnavailable                  ReasonCode = 0x88 //        \    |
	CodeServerBusy                         ReasonCode = 0x89 //        \    |
	CodeBanned                             ReasonCode = 0x8A //        \    |
	CodeServerShuttingDown                 ReasonCode = 0x8B //        \    |
	CodeBadAuthMethod                      ReasonCode = 0x8C //        \    |
	CodeSessionTakenOver                   ReasonCode = 0x8E //        \    |
	CodeKeepAliveTimeout                   ReasonCode = 0x8F //        \    |
	CodeTopicFilterNotValid                ReasonCode = 0x90 //        \    |
	CodePacketIDInUse                      ReasonCode = 0x91 //        \    |
	CodePacketIDNotFound                   ReasonCode = 0x92 //        \    |
	CodePacketTooLarge                     ReasonCode = 0x95 //        \    |
	CodeMessageRateTooHigh                 ReasonCode = 0x96 //        \    |
	CodeQuotaExceeded                      ReasonCode = 0x97 //        \    |
	CodeAdministrativeAction               ReasonCode = 0x98 //        \    |
	CodeDisconnectWithWillMessage          ReasonCode = 0x99 //        \    |
	CodeRetainUnavailable                  ReasonCode = 0x9A //        \    |
	CodeMaximumQoS                         ReasonCode = 0x9B //        \    |
	CodeUseAnotherServer                   ReasonCode = 0x9C //        \    |
	CodeServerMoved                        ReasonCode = 0x9D //        \    |
	CodeSharedSubscriptionNotSupported     ReasonCode = 0x9E //        \    |
	CodeConnectionRateExceeded             ReasonCode = 0x9F //        \    |
	CodeMaximumConnectTime                 ReasonCode = 0xA0 //        \    |
	CodeSubscriptionIDNotSupported         ReasonCode = 0xA1 //        \    |
	CodeWildcardSubscriptionsNotSupported  ReasonCode = 0xA2 //        \ <--|
)

nolint: golint // V3.1.1 \ V5.0

func (ReasonCode) Desc

func (c ReasonCode) Desc() string

Desc return code description

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 PacketType) 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 PacketType) (CodeIssuer, error)

PacketTypeDir check direction of packet type

func (ReasonCode) Value

func (c ReasonCode) Value() byte

Value convert reason code to byte type

type SubAckMessage

type SubAckMessage struct {
	// contains filtered or unexported fields
}

SubAckMessage 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 (*SubAckMessage) AddReturnCode

func (msg *SubAckMessage) AddReturnCode(ret ReasonCode) error

AddReturnCode adds a single QoS return value.

func (*SubAckMessage) AddReturnCodes

func (msg *SubAckMessage) 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 (*SubAckMessage) Desc

func (h *SubAckMessage) 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 (*SubAckMessage) Encode

func (h *SubAckMessage) Encode(dst []byte) (int, error)

func (*SubAckMessage) Flags

func (h *SubAckMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*SubAckMessage) Name

func (h *SubAckMessage) 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 (*SubAckMessage) PacketID

func (h *SubAckMessage) PacketID() (PacketID, error)

func (*SubAckMessage) PropertyForEach

func (h *SubAckMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*SubAckMessage) PropertyGet

func (h *SubAckMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*SubAckMessage) PropertySet

func (h *SubAckMessage) PropertySet(id PropertyID, val interface{}) error

func (*SubAckMessage) RemainingLength

func (h *SubAckMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*SubAckMessage) ReturnCodes

func (msg *SubAckMessage) ReturnCodes() []ReasonCode

ReturnCodes returns the list of QoS returns from the subscriptions sent in the SUBSCRIBE message.

func (*SubAckMessage) SetPacketID

func (msg *SubAckMessage) SetPacketID(v PacketID)

SetPacketID sets the ID of the packet.

func (*SubAckMessage) SetVersion

func (h *SubAckMessage) SetVersion(v ProtocolVersion)

func (*SubAckMessage) Size

func (h *SubAckMessage) Size() (int, error)

Size of message

func (*SubAckMessage) Type

func (h *SubAckMessage) Type() PacketType

Type returns the MessageType of the Message

func (*SubAckMessage) Version

func (h *SubAckMessage) Version() ProtocolVersion

type SubscribeMessage

type SubscribeMessage struct {
	// contains filtered or unexported fields
}

SubscribeMessage 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 (*SubscribeMessage) AddTopic

func (msg *SubscribeMessage) 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 (*SubscribeMessage) Desc

func (h *SubscribeMessage) 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 (*SubscribeMessage) Encode

func (h *SubscribeMessage) Encode(dst []byte) (int, error)

func (*SubscribeMessage) Flags

func (h *SubscribeMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*SubscribeMessage) Name

func (h *SubscribeMessage) 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 (*SubscribeMessage) PacketID

func (h *SubscribeMessage) PacketID() (PacketID, error)

func (*SubscribeMessage) PropertyForEach

func (h *SubscribeMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*SubscribeMessage) PropertyGet

func (h *SubscribeMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*SubscribeMessage) PropertySet

func (h *SubscribeMessage) PropertySet(id PropertyID, val interface{}) error

func (*SubscribeMessage) RemainingLength

func (h *SubscribeMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*SubscribeMessage) RemoveTopic

func (msg *SubscribeMessage) 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 (*SubscribeMessage) SetPacketID

func (msg *SubscribeMessage) SetPacketID(v PacketID)

SetPacketID sets the ID of the packet.

func (*SubscribeMessage) SetVersion

func (h *SubscribeMessage) SetVersion(v ProtocolVersion)

func (*SubscribeMessage) Size

func (h *SubscribeMessage) Size() (int, error)

Size of message

func (*SubscribeMessage) Topics

func (msg *SubscribeMessage) Topics() omap.Map

Topics returns a list of topics sent by the Client.

func (*SubscribeMessage) Type

func (h *SubscribeMessage) Type() PacketType

Type returns the MessageType of the Message

func (*SubscribeMessage) Version

func (h *SubscribeMessage) 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) QoS

func (s SubscriptionOptions) QoS() QosType

QoS quality of service

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() byte

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 UnSubAckMessage

type UnSubAckMessage struct {
	// contains filtered or unexported fields
}

UnSubAckMessage The UNSUBACK Packet is sent by the Server to the Client to confirm receipt of an UNSUBSCRIBE Packet.

func (*UnSubAckMessage) AddReturnCode

func (msg *UnSubAckMessage) AddReturnCode(ret ReasonCode) error

AddReturnCode adds a single QoS return value.

func (*UnSubAckMessage) AddReturnCodes

func (msg *UnSubAckMessage) 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 (*UnSubAckMessage) Desc

func (h *UnSubAckMessage) 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 (*UnSubAckMessage) Encode

func (h *UnSubAckMessage) Encode(dst []byte) (int, error)

func (*UnSubAckMessage) Flags

func (h *UnSubAckMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*UnSubAckMessage) Name

func (h *UnSubAckMessage) 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 (*UnSubAckMessage) PacketID

func (h *UnSubAckMessage) PacketID() (PacketID, error)

func (*UnSubAckMessage) PropertyForEach

func (h *UnSubAckMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*UnSubAckMessage) PropertyGet

func (h *UnSubAckMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*UnSubAckMessage) PropertySet

func (h *UnSubAckMessage) PropertySet(id PropertyID, val interface{}) error

func (*UnSubAckMessage) RemainingLength

func (h *UnSubAckMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*UnSubAckMessage) ReturnCodes

func (msg *UnSubAckMessage) ReturnCodes() []ReasonCode

ReturnCodes returns the list of QoS returns from the subscriptions sent in the SUBSCRIBE message.

func (*UnSubAckMessage) SetPacketID

func (msg *UnSubAckMessage) SetPacketID(v PacketID)

SetPacketID sets the ID of the packet.

func (*UnSubAckMessage) SetVersion

func (h *UnSubAckMessage) SetVersion(v ProtocolVersion)

func (*UnSubAckMessage) Size

func (h *UnSubAckMessage) Size() (int, error)

Size of message

func (*UnSubAckMessage) Type

func (h *UnSubAckMessage) Type() PacketType

Type returns the MessageType of the Message

func (*UnSubAckMessage) Version

func (h *UnSubAckMessage) Version() ProtocolVersion

type UnSubscribeMessage

type UnSubscribeMessage struct {
	// contains filtered or unexported fields
}

UnSubscribeMessage An UNSUBSCRIBE Packet is sent by the Client to the Server, to unsubscribe from topics.

func (*UnSubscribeMessage) AddTopic

func (msg *UnSubscribeMessage) AddTopic(topic string) error

AddTopic adds a single topic to the message.

func (*UnSubscribeMessage) Desc

func (h *UnSubscribeMessage) 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 (*UnSubscribeMessage) Encode

func (h *UnSubscribeMessage) Encode(dst []byte) (int, error)

func (*UnSubscribeMessage) Flags

func (h *UnSubscribeMessage) Flags() byte

Flags returns the fixed header flags for this message.

func (*UnSubscribeMessage) Name

func (h *UnSubscribeMessage) 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 (*UnSubscribeMessage) PacketID

func (h *UnSubscribeMessage) PacketID() (PacketID, error)

func (*UnSubscribeMessage) PropertyForEach

func (h *UnSubscribeMessage) PropertyForEach(f func(PropertyID, interface{})) error

func (*UnSubscribeMessage) PropertyGet

func (h *UnSubscribeMessage) PropertyGet(id PropertyID) (interface{}, error)

func (*UnSubscribeMessage) PropertySet

func (h *UnSubscribeMessage) PropertySet(id PropertyID, val interface{}) error

func (*UnSubscribeMessage) RemainingLength

func (h *UnSubscribeMessage) RemainingLength() int32

RemainingLength returns the length of the non-fixed-header part of the message.

func (*UnSubscribeMessage) RemoveTopic

func (msg *UnSubscribeMessage) 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 (*UnSubscribeMessage) SetPacketID

func (msg *UnSubscribeMessage) SetPacketID(v PacketID)

SetPacketID sets the ID of the packet.

func (*UnSubscribeMessage) SetVersion

func (h *UnSubscribeMessage) SetVersion(v ProtocolVersion)

func (*UnSubscribeMessage) Size

func (h *UnSubscribeMessage) Size() (int, error)

Size of message

func (*UnSubscribeMessage) Topics

func (msg *UnSubscribeMessage) Topics() omap.Map

Topics returns a list of topics sent by the Client.

func (*UnSubscribeMessage) Type

func (h *UnSubscribeMessage) Type() PacketType

Type returns the MessageType of the Message

func (*UnSubscribeMessage) Version

func (h *UnSubscribeMessage) Version() ProtocolVersion

Jump to

Keyboard shortcuts

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