Documentation ¶
Index ¶
- Constants
- Variables
- func NewReasonCodeError(c ReasonCode, message string) error
- func ValidateID(p byte, i byte) bool
- type FixedHeader
- type Packet
- func (pk *Packet) ConnackDecode(buf []byte) error
- func (pk *Packet) ConnackDecodeV5(buf []byte) error
- func (pk *Packet) ConnackEncode(buf *bytes.Buffer) error
- func (pk *Packet) ConnackEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) ConnectDecode(buf []byte) error
- func (pk *Packet) ConnectDecodeV5(buf []byte) error
- func (pk *Packet) ConnectEncode(buf *bytes.Buffer) error
- func (pk *Packet) ConnectEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) ConnectValidate() (b byte, err error)
- func (pk *Packet) ConnectValidateV5() (b byte, err error)
- func (pk *Packet) DisconnectDecodeV5(buf []byte) error
- func (pk *Packet) DisconnectEncode(buf *bytes.Buffer) error
- func (pk *Packet) DisconnectEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) FormatID() string
- func (pk *Packet) PingreqEncode(buf *bytes.Buffer) error
- func (pk *Packet) PingreqEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) PingrespEncode(buf *bytes.Buffer) error
- func (pk *Packet) PingrespEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) PubackDecode(buf []byte) error
- func (pk *Packet) PubackDecodeV5(buf []byte) error
- func (pk *Packet) PubackEncode(buf *bytes.Buffer) error
- func (pk *Packet) PubackEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) PubcompDecode(buf []byte) error
- func (pk *Packet) PubcompDecodeV5(buf []byte) error
- func (pk *Packet) PubcompEncode(buf *bytes.Buffer) error
- func (pk *Packet) PubcompEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) PublishCopy() Packet
- func (pk *Packet) PublishCopyV5() Packet
- func (pk *Packet) PublishDecode(buf []byte) error
- func (pk *Packet) PublishDecodeV5(buf []byte) error
- func (pk *Packet) PublishEncode(buf *bytes.Buffer) error
- func (pk *Packet) PublishEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) PublishValidate() (byte, error)
- func (pk *Packet) PublishValidateV5() (byte, error)
- func (pk *Packet) PubrecDecode(buf []byte) error
- func (pk *Packet) PubrecDecodeV5(buf []byte) error
- func (pk *Packet) PubrecEncode(buf *bytes.Buffer) error
- func (pk *Packet) PubrecEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) PubrelDecode(buf []byte) error
- func (pk *Packet) PubrelDecodeV5(buf []byte) error
- func (pk *Packet) PubrelEncode(buf *bytes.Buffer) error
- func (pk *Packet) PubrelEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) SubackDecode(buf []byte) error
- func (pk *Packet) SubackDecodeV5(buf []byte) error
- func (pk *Packet) SubackEncode(buf *bytes.Buffer) error
- func (pk *Packet) SubackEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) SubscribeDecode(buf []byte) error
- func (pk *Packet) SubscribeDecodeV5(buf []byte) error
- func (pk *Packet) SubscribeEncode(buf *bytes.Buffer) error
- func (pk *Packet) SubscribeEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) SubscribeValidate() (byte, error)
- func (pk *Packet) SubscribeValidateV5() (byte, error)
- func (pk *Packet) UnsubackDecode(buf []byte) error
- func (pk *Packet) UnsubackDecodeV5(buf []byte) error
- func (pk *Packet) UnsubackEncode(buf *bytes.Buffer) error
- func (pk *Packet) UnsubackEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) UnsubscribeDecode(buf []byte) error
- func (pk *Packet) UnsubscribeDecodeV5(buf []byte) error
- func (pk *Packet) UnsubscribeEncode(buf *bytes.Buffer) error
- func (pk *Packet) UnsubscribeEncodeV5(buf *bytes.Buffer) error
- func (pk *Packet) UnsubscribeValidate() (byte, error)
- func (pk *Packet) UnsubscribeValidateV5() (byte, error)
- type Properties
- type ReasonCode
- type SubOptions
- type User
Constants ¶
const ( Reserved byte = iota Connect // 1 Connack // 2 Publish // 3 Puback // 4 Pubrec // 5 Pubrel // 6 Pubcomp // 7 Subscribe // 8 Suback // 9 Unsubscribe // 10 Unsuback // 11 Pingreq // 12 Pingresp // 13 Disconnect // 14 Auth // 15 Accepted byte = 0x00 Failed byte = 0xFF CodeConnectBadProtocolVersion byte = 0x01 CodeConnectBadClientID byte = 0x02 CodeConnectBadAuthValues byte = 0x04 CodeConnectNotAuthorised byte = 0x05 CodeConnectNetworkError byte = 0xFE CodeConnectProtocolViolation byte = 0xFF ErrSubAckNetworkError byte = 0x80 )
All of the valid packet types and their packet identifier.
const ( PropPayloadFormat byte = 1 PropMessageExpiry byte = 2 PropContentType byte = 3 PropResponseTopic byte = 8 PropCorrelationData byte = 9 PropSubscriptionIdentifier byte = 11 PropSessionExpiryInterval byte = 17 PropAssignedClientID byte = 18 PropServerKeepAlive byte = 19 PropAuthMethod byte = 21 PropAuthData byte = 22 PropRequestProblemInfo byte = 23 PropWillDelayInterval byte = 24 PropRequestResponseInfo byte = 25 PropResponseInfo byte = 26 PropServerReference byte = 28 PropReasonString byte = 31 PropReceiveMaximum byte = 33 PropTopicAliasMaximum byte = 34 PropTopicAlias byte = 35 PropMaximumQOS byte = 36 PropRetainAvailable byte = 37 PropUser byte = 38 PropMaximumPacketSize byte = 39 PropWildcardSubAvailable byte = 40 PropSubIDAvailable byte = 41 )
PropPayloadFormat, etc are the list of property codes for the MQTT packet properties
Variables ¶
var ( // CONNECT ErrMalformedProtocolName = errors.New("malformed packet: protocol name") ErrMalformedProtocolVersion = errors.New("malformed packet: protocol version") ErrMalformedFlags = errors.New("malformed packet: flags") ErrMalformedKeepalive = errors.New("malformed packet: keepalive") ErrMalformedClientID = errors.New("malformed packet: client id") ErrMalformedWillTopic = errors.New("malformed packet: will topic") ErrMalformedWillMessage = errors.New("malformed packet: will message") ErrMalformedUsername = errors.New("malformed packet: username") ErrMalformedPassword = errors.New("malformed packet: password") ErrMalformedProperties = errors.New("malformed packet: properties") ErrMalformedWillProperties = errors.New("malformed packet: will properties") // CONNACK ErrMalformedSessionPresent = errors.New("malformed packet: session present") ErrMalformedReturnCode = errors.New("malformed packet: return code") // PUBLISH ErrMalformedTopic = errors.New("malformed packet: topic name") ErrMalformedPacketID = errors.New("malformed packet: packet id") ErrMalformedPayload = errors.New("malformed packet: payload") // SUBSCRIBE ErrMalformedQoS = errors.New("malformed packet: qos") // PACKETS ErrProtocolViolation = errors.New("protocol violation") ErrOffsetStrOutOfRange = errors.New("offset string out of range") ErrOffsetBytesOutOfRange = errors.New("offset bytes out of range") ErrOffsetByteOutOfRange = errors.New("offset byte out of range") ErrOffsetBoolOutOfRange = errors.New("offset bool out of range") ErrOffsetUintOutOfRange = errors.New("offset uint out of range") ErrOffsetStrInvalidUTF8 = errors.New("offset string invalid utf8") ErrInvalidFlags = errors.New("invalid flags set for packet") ErrOversizedLengthIndicator = errors.New("protocol violation: oversized length indicator") ErrMissingPacketID = errors.New("missing packet id") ErrSurplusPacketID = errors.New("surplus packet id") )
var ValidProperties = map[byte]map[byte]struct{}{ PropPayloadFormat: {Publish: {}}, PropMessageExpiry: {Publish: {}}, PropContentType: {Publish: {}}, PropResponseTopic: {Publish: {}}, PropCorrelationData: {Publish: {}}, PropTopicAlias: {Publish: {}}, PropSubscriptionIdentifier: {Publish: {}, Subscribe: {}}, PropSessionExpiryInterval: {Connect: {}, Connack: {}, Disconnect: {}}, PropAssignedClientID: {Connack: {}}, PropServerKeepAlive: {Connack: {}}, PropWildcardSubAvailable: {Connack: {}}, PropSubIDAvailable: {Connack: {}}, PropSharedSubAvailable: {Connack: {}}, PropRetainAvailable: {Connack: {}}, PropResponseInfo: {Connack: {}}, PropAuthMethod: {Connect: {}, Connack: {}, Auth: {}}, PropAuthData: {Connect: {}, Connack: {}, Auth: {}}, PropRequestProblemInfo: {Connect: {}}, PropWillDelayInterval: {Connect: {}}, PropRequestResponseInfo: {Connect: {}}, PropServerReference: {Connack: {}, Disconnect: {}}, PropReasonString: {Connack: {}, Puback: {}, Pubrec: {}, Pubrel: {}, Pubcomp: {}, Suback: {}, Unsuback: {}, Disconnect: {}, Auth: {}}, PropReceiveMaximum: {Connect: {}, Connack: {}}, PropTopicAliasMaximum: {Connect: {}, Connack: {}}, PropMaximumQOS: {Connect: {}, Connack: {}}, PropMaximumPacketSize: {Connect: {}, Connack: {}}, PropUser: {Connect: {}, Connack: {}, Publish: {}, Puback: {}, Pubrec: {}, Pubrel: {}, Pubcomp: {}, Subscribe: {}, Unsubscribe: {}, Suback: {}, Unsuback: {}, Disconnect: {}, Auth: {}}, }
ValidProperties is a map of the various properties and the PacketTypes that property is valid for.
Functions ¶
func NewReasonCodeError ¶
func NewReasonCodeError(c ReasonCode, message string) error
NewReasonCodeError returns a new error based on the given reason code.
func ValidateID ¶
ValidateID takes a PacketType and a property name and returns a boolean indicating if that property is valid for that PacketType
Types ¶
type FixedHeader ¶
type FixedHeader struct { Remaining int // the number of remaining bytes in the payload. Type byte // the type of the packet (PUBLISH, SUBSCRIBE, etc) from bits 7 - 4 (byte 1). Qos byte // indicates the quality of service expected. Dup bool // indicates if the packet was already sent at an earlier time. Retain bool // whether the message should be retained. }
FixedHeader contains the values of the fixed header portion of the MQTT packet.
func (*FixedHeader) Decode ¶
func (fh *FixedHeader) Decode(headerByte byte) error
decode extracts the specification bits from the header byte.
func (*FixedHeader) Encode ¶
func (fh *FixedHeader) Encode(buf *bytes.Buffer)
Encode encodes the FixedHeader and returns a bytes buffer.
type Packet ¶
type Packet struct { FixedHeader FixedHeader AllowClients []string // For use with OnMessage event hook. Topics []string ReturnCodes []byte ProtocolName []byte Payload []byte Username []byte Password []byte WillMessage []byte ClientIdentifier string TopicName string WillTopic string PacketID uint16 Keepalive uint16 ReturnCode byte //v5.0 ReasonCode ProtocolVersion byte WillQos byte ReservedBit byte CleanSession bool //v5.0 CleanStart WillFlag bool WillRetain bool UsernameFlag bool PasswordFlag bool SessionPresent bool SubOss []SubOptions Properties *Properties WillProperties *Properties }
Packet is an MQTT packet. Instead of providing a packet interface and variant packet structs, this is a single concrete packet type to cover all packet types, which allows us to take advantage of various compiler optimizations.
func (*Packet) ConnackDecode ¶
ConnackDecode decodes a Connack packet.
func (*Packet) ConnackDecodeV5 ¶
ConnackDecodeV5 decodes a Connack packet.
func (*Packet) ConnackEncode ¶
ConnackEncode encodes a Connack packet.
func (*Packet) ConnackEncodeV5 ¶
ConnackEncodeV5 encodes a Connack packet.
func (*Packet) ConnectDecode ¶
ConnectDecode decodes a connect packet.
func (*Packet) ConnectDecodeV5 ¶
ConnectDecodeV5 decodes a connect packet.
func (*Packet) ConnectEncode ¶
ConnectEncode encodes a connect packet.
func (*Packet) ConnectEncodeV5 ¶
ConnectEncodeV5 encodes a connect packet.
func (*Packet) ConnectValidate ¶
ConnectValidate ensures the connect packet is compliant.
func (*Packet) ConnectValidateV5 ¶
ConnectValidateV5 ensures the connect packet is compliant.
func (*Packet) DisconnectDecodeV5 ¶
DisconnectDecodeV5 decodes a Disconnect packet.
func (*Packet) DisconnectEncode ¶
DisconnectEncode encodes a Disconnect packet.
func (*Packet) DisconnectEncodeV5 ¶
DisconnectEncodeV5 encodes a Disconnect packet.
func (*Packet) PingreqEncode ¶
PingreqEncode encodes a Pingreq packet.
func (*Packet) PingreqEncodeV5 ¶
PingreqEncodeV5 encodes a Pingreq packet.
func (*Packet) PingrespEncode ¶
PingrespEncode encodes a Pingresp packet.
func (*Packet) PingrespEncodeV5 ¶
PingrespEncodeV5 encodes a Pingresp packet.
func (*Packet) PubackDecode ¶
PubackDecode decodes a Puback packet.
func (*Packet) PubackDecodeV5 ¶
PubackDecodeV5 decodes a Puback packet.
func (*Packet) PubackEncode ¶
PubackEncode encodes a Puback packet.
func (*Packet) PubackEncodeV5 ¶
PubackEncodeV5 encodes a Puback packet.
func (*Packet) PubcompDecode ¶
PubcompDecode decodes a Pubcomp packet.
func (*Packet) PubcompDecodeV5 ¶
PubcompDecodeV5 decodes a Pubcomp packet.
func (*Packet) PubcompEncode ¶
PubcompEncode encodes a Pubcomp packet.
func (*Packet) PubcompEncodeV5 ¶
PubcompEncodeV5 encodes a Pubcomp packet.
func (*Packet) PublishCopy ¶
PublishCopy creates a new instance of Publish packet bearing the same payload and destination topic, but with an empty header for inheriting new QoS flags, etc.
func (*Packet) PublishCopyV5 ¶
PublishCopyV5 creates a new instance of Publish packet bearing the same payload and destination topic, but with an empty header for inheriting new QoS flags, etc.
func (*Packet) PublishDecode ¶
PublishDecode extracts the data values from the packet.
func (*Packet) PublishDecodeV5 ¶
PublishDecodeV5 extracts the data values from the packet.
func (*Packet) PublishEncode ¶
PublishEncode encodes a Publish packet.
func (*Packet) PublishEncodeV5 ¶
PublishEncodeV5 encodes a Publish packet.
func (*Packet) PublishValidate ¶
PublishValidate validates a publish packet.
func (*Packet) PublishValidateV5 ¶
PublishValidateV5 validates a publish packet.
func (*Packet) PubrecDecode ¶
PubrecDecode decodes a Pubrec packet.
func (*Packet) PubrecDecodeV5 ¶
PubrecDecodeV5 decodes a Pubrec packet.
func (*Packet) PubrecEncode ¶
PubrecEncode encodes a Pubrec packet.
func (*Packet) PubrecEncodeV5 ¶
PubrecEncodeV5 encodes a Pubrec packet.
func (*Packet) PubrelDecode ¶
PubrelDecode decodes a Pubrel packet.
func (*Packet) PubrelDecodeV5 ¶
PubrelDecodeV5 decodes a Pubrel packet.
func (*Packet) PubrelEncode ¶
PubrelEncode encodes a Pubrel packet.
func (*Packet) PubrelEncodeV5 ¶
PubrelEncodeV5 encodes a Pubrel packet.
func (*Packet) SubackDecode ¶
SubackDecode decodes a Suback packet.
func (*Packet) SubackDecodeV5 ¶
SubackDecodeV5 decodes a Suback packet.
func (*Packet) SubackEncode ¶
SubackEncode encodes a Suback packet.
func (*Packet) SubackEncodeV5 ¶
SubackEncodeV5 encodes a Suback packet.
func (*Packet) SubscribeDecode ¶
SubscribeDecode decodes a Subscribe packet.
func (*Packet) SubscribeDecodeV5 ¶
SubscribeDecodeV5 decodes a Subscribe packet.
func (*Packet) SubscribeEncode ¶
SubscribeEncode encodes a Subscribe packet.
func (*Packet) SubscribeEncodeV5 ¶
SubscribeEncodeV5 encodes a Subscribe packet.
func (*Packet) SubscribeValidate ¶
SubscribeValidate ensures the packet is compliant.
func (*Packet) SubscribeValidateV5 ¶
SubscribeValidateV5 ensures the packet is compliant.
func (*Packet) UnsubackDecode ¶
UnsubackDecode decodes an Unsuback packet.
func (*Packet) UnsubackDecodeV5 ¶
UnsubackDecodeV5 decodes an Unsuback packet.
func (*Packet) UnsubackEncode ¶
UnsubackEncode encodes an Unsuback packet.
func (*Packet) UnsubackEncodeV5 ¶
UnsubackEncodeV5 encodes an Unsuback packet.
func (*Packet) UnsubscribeDecode ¶
UnsubscribeDecode decodes an Unsubscribe packet.
func (*Packet) UnsubscribeDecodeV5 ¶
UnsubscribeDecodeV5 decodes an Unsubscribe packet.
func (*Packet) UnsubscribeEncode ¶
UnsubscribeEncode encodes an Unsubscribe packet.
func (*Packet) UnsubscribeEncodeV5 ¶
UnsubscribeEncodeV5 encodes an Unsubscribe packet.
func (*Packet) UnsubscribeValidate ¶
UnsubscribeValidate validates an Unsubscribe packet.
func (*Packet) UnsubscribeValidateV5 ¶
UnsubscribeValidateV5 validates an Unsubscribe packet.
type Properties ¶
type Properties struct { // PayloadFormat indicates the format of the payload of the message // 0 is unspecified bytes // 1 is UTF8 encoded character data PayloadFormat *byte `json:"payload_format,omitempty" msg:"payload_format,omitempty"` // MessageExpiry is the lifetime of the message in seconds MessageExpiry *uint32 `json:"msg_expiry,omitempty" msg:"msg_expiry,omitempty"` // ContentType is a UTF8 string describing the content of the message // for example it could be a MIME type ContentType string `json:"content_type,omitempty" msg:"content_type,omitempty"` // ResponseTopic is a UTF8 string indicating the topic name to which any // response to this message should be sent ResponseTopic string `json:"resp_topic,omitempty" msg:"resp_topic,omitempty"` // CorrelationData is binary data used to associate future response // messages with the original request message CorrelationData []byte `json:"corr_data,omitempty" msg:"corr_data,omitempty"` // SubscriptionIdentifier is an identifier of the subscription to which // the Publish matched SubscriptionIdentifier *int `json:"sub_id,omitempty" msg:"sub_id,omitempty"` // SessionExpiryInterval is the time in seconds after a client disconnects // that the server should retain the session information (subscriptions etc) SessionExpiryInterval *uint32 `json:"sei,omitempty" msg:"sei,omitempty"` // AssignedClientID is the server assigned client identifier in the case // that a client connected without specifying a clientID the server // generates one and returns it in the Connack AssignedClientID string `json:"acid,omitempty" msg:"acid,omitempty"` // ServerKeepAlive allows the server to specify in the Connack packet // the time in seconds to be used as the keep alive value ServerKeepAlive *uint16 `json:"ska,omitempty" msg:"ska,omitempty"` // AuthMethod is a UTF8 string containing the name of the authentication // method to be used for extended authentication AuthMethod string `json:"auth_method,omitempty" msg:"auth_method,omitempty"` // AuthData is binary data containing authentication data AuthData []byte `json:"auth_data,omitempty" msg:"auth_data,omitempty"` // RequestProblemInfo is used by the Client to indicate to the server to // include the Reason String and/or User Properties in case of failures RequestProblemInfo *byte `json:"rpi,omitempty" msg:"rpi,omitempty"` // WillDelayInterval is the number of seconds the server waits after the // point at which it would otherwise send the will message before sending // it. The client reconnecting before that time expires causes the server // to cancel sending the will WillDelayInterval *uint32 `json:"wdi,omitempty" msg:"wdi,omitempty"` // RequestResponseInfo is used by the Client to request the Server provide // Response Information in the Connack RequestResponseInfo *byte `json:"rri,omitempty" msg:"rri,omitempty"` // ResponseInfo is a UTF8 encoded string that can be used as the basis for // createing a Response Topic. The way in which the Client creates a // Response Topic from the Response Information is not defined. A common // use of this is to pass a globally unique portion of the topic tree which // is reserved for this Client for at least the lifetime of its Session. This // often cannot just be a random name as both the requesting Client and the // responding Client need to be authorized to use it. It is normal to use this // as the root of a topic tree for a particular Client. For the Server to // return this information, it normally needs to be correctly configured. // Using this mechanism allows this configuration to be done once in the // Server rather than in each Client ResponseInfo string `json:"resp_info,omitempty" msg:"resp_info,omitempty"` // ServerReference is a UTF8 string indicating another server the client // can use ServerReference string `json:"server_ref,omitempty" msg:"server_ref,omitempty"` // ReasonString is a UTF8 string representing the reason associated with // this response, intended to be human readable for diagnostic purposes ReasonString string `json:"reason,omitempty" msg:"reason,omitempty"` // ReceiveMaximum is the maximum number of QOS1 & 2 messages allowed to be // 'inflight' (not having received a PUBACK/PUBCOMP response for) ReceiveMaximum *uint16 `json:"rec_max,omitempty" msg:"rec_max,omitempty"` // TopicAliasMaximum is the highest value permitted as a Topic Alias TopicAliasMaximum *uint16 `json:"tam,omitempty" msg:"tam,omitempty"` // TopicAlias is used in place of the topic string to reduce the size of // packets for repeated messages on a topic TopicAlias *uint16 `json:"topic_alias,omitempty" msg:"topic_alias,omitempty"` // MaximumQOS is the highest QOS level permitted for a Publish MaximumQOS *byte `json:"max_qos,omitempty" msg:"max_qos,omitempty"` // RetainAvailable indicates whether the server supports messages with the // retain flag set RetainAvailable *byte `json:"retain_ava,omitempty" msg:"retain_ava,omitempty"` // User is a slice of user provided properties (key and value) User []User `json:"user,omitempty" msg:"user,omitempty"` // MaximumPacketSize allows the client or server to specify the maximum packet // size in bytes that they support MaximumPacketSize *uint32 `json:"mps,omitempty" msg:"mps,omitempty"` // WildcardSubAvailable indicates whether wildcard subscriptions are permitted WildcardSubAvailable *byte `json:"wsa,omitempty" msg:"wsa,omitempty"` // SubIDAvailable indicates whether subscription identifiers are supported SubIDAvailable *byte `json:"sid_ava,omitempty" msg:"sid_ava,omitempty"` SharedSubAvailable *byte `json:"ssa,omitempty" msg:"ssa,omitempty"` }
Properties is a struct representing the all the described properties allowed by the MQTT protocol, determining the validity of a property relvative to the packettype it was received in is provided by the ValidateID function
func (*Properties) Pack ¶
func (i *Properties) Pack(p byte) []byte
Pack takes all the defined properties for an Properties and produces a slice of bytes representing the wire format for the information
func (*Properties) PackBuf ¶
func (i *Properties) PackBuf(p byte) *bytes.Buffer
PackBuf will create a bytes.Buffer of the packed properties, it will only pack the properties appropriate to the packet type p even though other properties may exist, it will silently ignore them
func (*Properties) String ¶
func (p *Properties) String() string
type ReasonCode ¶
type ReasonCode byte
ReasonCode indicates the result of an operation
const ( Success ReasonCode = 0x00 // Success NormalDisconnection ReasonCode = 0x00 // Normal disconnection GrantedQoS0 ReasonCode = 0x00 // Granted QoS 0 GrantedQoS1 ReasonCode = 0x01 // Granted QoS 1 GrantedQoS2 ReasonCode = 0x02 // Granted QoS 2 DisconnectWithWillMessage ReasonCode = 0x04 // Disconnect with Will Message NoMatchingSubscribers ReasonCode = 0x10 // No matching subscribers NoSubscriptionExisted ReasonCode = 0x11 // No subscription existed ContinueAuthentication ReasonCode = 0x18 // Continue authentication ReAuthenticate ReasonCode = 0x19 // Re-authenticate UnspecifiedError ReasonCode = 0x80 // Unspecified error MalformedPacket ReasonCode = 0x81 // Malformed Packet ProtocolError ReasonCode = 0x82 // Protocol Error ImplementationSpecificError ReasonCode = 0x83 // Implementation specific error UnsupportedProtocolVersion ReasonCode = 0x84 // Unsupported Protocol Version ClientIdentifierNotValid ReasonCode = 0x85 // Client Identifier not valid BadUsernameOrPassword ReasonCode = 0x86 // Bad User Name or Password NotAuthorized ReasonCode = 0x87 // Not authorized ServerBusy ReasonCode = 0x89 // Server busy Banned ReasonCode = 0x8A // Banned ServerShuttingDown ReasonCode = 0x8B // Server shutting down BadAuthenticationMethod ReasonCode = 0x8C // Bad authentication method KeepAliveTimeout ReasonCode = 0x8D // Keep Alive timeout SessionTakenOver ReasonCode = 0x8E // Session taken over TopicFilterInvalid ReasonCode = 0x8F // Topic Filter invalid TopicNameInvalid ReasonCode = 0x90 // Topic Name invalid PacketIdentifierInUse ReasonCode = 0x91 // Packet Identifier in use PacketIdentifierNotFound ReasonCode = 0x92 // Packet Identifier not found ReceiveMaximumExceeded ReasonCode = 0x93 // Receive Maximum exceeded TopicAliasInvalid ReasonCode = 0x94 // Topic Alias invalid PacketTooLarge ReasonCode = 0x95 // Packet too large MessageRateTooHigh ReasonCode = 0x96 // Message rate too high QuotaExceeded ReasonCode = 0x97 // Quota exceeded AdministrativeAction ReasonCode = 0x98 // Administrative action PayloadFormatInvalid ReasonCode = 0x99 // Payload format invalid RetainNotSupported ReasonCode = 0x9A // Retain not supported QoSNotSupported ReasonCode = 0x9B // QoS not supported UseAnotherServer ReasonCode = 0x9C // Use another server ServerMoved ReasonCode = 0x9D // Server moved ConnectionRateExceeded ReasonCode = 0x9F // Connection rate exceeded MaximumConnectTime ReasonCode = 0xA0 // Maximum connect time SubscriptionIdentifiersNotSupported ReasonCode = 0xA1 // Subscription Identifiers not supported WildcardSubscriptionsNotSupported ReasonCode = 0xA2 // Wildcard Subscriptions not supported )
ReasonCode Values.
func (ReasonCode) IsError ¶
func (c ReasonCode) IsError() bool
IsError returns whether the reason code is an error code.
func (ReasonCode) String ¶
func (c ReasonCode) String() string
type SubOptions ¶
type SubOptions struct { // Qos is the QoS level of the subscription. // 0 = At most once delivery // 1 = At least once delivery // 2 = Exactly once delivery QoS byte `json:"qos,omitempty" msg:"qos,omitempty"` // RetainHandling specifies whether retained messages are sent when the subscription is established. // 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 RetainHandling byte `json:"retain_hd,omitempty" msg:"retain_hd,omitempty"` // NoLocal is the No Local option. // If the value is 1, Application Messages MUST NOT be forwarded to a connection with a ClientID equal to the ClientID of the publishing connection NoLocal bool `json:"no_local,omitempty" msg:"no_local,omitempty"` // RetainAsPublished is the Retain As Published option. // If 1, Application Messages forwarded using this subscription keep the RETAIN flag they were published with. // If 0, 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. RetainAsPublished bool `json:"rap,omitempty" msg:"rap,omitempty"` }
subOptions is the struct representing the options for a subscription