Documentation ¶
Index ¶
- func IsMessageTypeAvailable(v uint8) bool
- func IsQoSAvaliable(v uint8) bool
- func IsReasonCodeAvailable(v uint8) bool
- func WithQoS(qos QoSLevel) option
- func WithRetain() option
- func WriteFrame(w io.Writer, m Encoder) error
- type Auth
- type AuthProperty
- type ConnAck
- type ConnAckProperty
- type Connect
- type ConnectProperty
- type Disconnect
- type DisconnectProperty
- type Encoder
- type Frame
- type MessageType
- type Packet
- type PingReq
- type PingResp
- type Property
- func (p *Property) ToAuth() *AuthProperty
- func (p *Property) ToConnAck() *ConnAckProperty
- func (p *Property) ToConnect() *ConnectProperty
- func (p *Property) ToDisconnect() *DisconnectProperty
- func (p *Property) ToPubAck() *PubAckProperty
- func (p *Property) ToPubComp() *PubCompProperty
- func (p *Property) ToPubRec() *PubRecProperty
- func (p *Property) ToPubRel() *PubRelProperty
- func (p *Property) ToPublish() *PublishProperty
- func (p *Property) ToSubAck() *SubAckProperty
- func (p *Property) ToSubscribe() *SubscribeProperty
- func (p *Property) ToUnsubAck() *UnsubAckProperty
- func (p *Property) ToUnsubscribe() *UnsubscribeProperty
- func (p *Property) ToWill() *WillProperty
- type PropertyType
- type PubAck
- type PubAckProperty
- type PubComp
- type PubCompProperty
- type PubRec
- type PubRecProperty
- type PubRel
- type PubRelProperty
- type Publish
- type PublishProperty
- type QoSLevel
- type ReasonCode
- type SubAck
- type SubAckProperty
- type Subscribe
- type SubscribeProperty
- type SubscribeTopic
- type UnsubAck
- type UnsubAckProperty
- type Unsubscribe
- type UnsubscribeProperty
- type WillProperty
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMessageTypeAvailable ¶
func IsQoSAvaliable ¶
func IsReasonCodeAvailable ¶
func WithRetain ¶
func WithRetain() option
Types ¶
type Auth ¶
type Auth struct { *Frame ReasonCode ReasonCode Property *AuthProperty }
func NewAuth ¶
func NewAuth(reason ReasonCode, opts ...option) *Auth
type AuthProperty ¶
type AuthProperty struct { AuthenticationMethod string AuthenticationData []byte ReasonString string UserProperty map[string]string }
func (*AuthProperty) ToProp ¶
func (a *AuthProperty) ToProp() *Property
type ConnAck ¶
type ConnAck struct { *Frame Property *ConnAckProperty SessionPresentFlag bool ReasonCode ReasonCode }
func NewConnAck ¶
func NewConnAck(code ReasonCode, opts ...option) *ConnAck
type ConnAckProperty ¶
type ConnAckProperty struct { SessionExpiryInterval uint32 AssignedClientIdentifier string ServerKeepAlive uint16 AuthenticationMethod string AuthenticationData []byte ResponseInformation string ServerReference string ReasonString string ReceiveMaximum uint16 TopicAliasMaximum uint16 MaximumQoS uint8 RetainAvalilable bool UserProperty map[string]string MaximumPacketSize uint32 WildcardSubscriptionAvailable bool SubscrptionIdentifierAvailable bool }
func (*ConnAckProperty) ToProp ¶
func (c *ConnAckProperty) ToProp() *Property
type Connect ¶
type Connect struct { *Frame // Protocol defintions ProtocolName string ProtocolVersion uint8 // Connection flags FlagUsername bool FlagPassword bool WillRetain bool WillQoS QoSLevel FlagWill bool CleanStart bool KeepAlive uint16 // Connection properties Property *ConnectProperty WillProperty *WillProperty // Payloads ClientId string WillTopic string WillPayload string Username string Password []byte }
func NewConnect ¶
func NewConnect(opts ...option) *Connect
type ConnectProperty ¶
type ConnectProperty struct { SessionExpiryInterval uint32 AuthenticationMethod string AuthenticationData []byte RequestProblemInformation bool RequestResponseInformation bool ReceiveMaximum uint16 TopicAliasMaximum uint16 UserProperty map[string]string MaximumPacketSize uint32 // Extra field for application: stack auth challenge data ChallengeData interface{} }
func (*ConnectProperty) ToProp ¶
func (c *ConnectProperty) ToProp() *Property
type Disconnect ¶
type Disconnect struct { *Frame ReasonCode ReasonCode Property *DisconnectProperty }
func NewDisconnect ¶
func NewDisconnect(code ReasonCode, opts ...option) *Disconnect
func ParseDisconnect ¶
func ParseDisconnect(f *Frame, p []byte) (d *Disconnect, err error)
func (*Disconnect) Encode ¶
func (d *Disconnect) Encode() ([]byte, error)
type DisconnectProperty ¶
type DisconnectProperty struct { SessionExpiryInterval uint32 ServerReference string ReasonString string UserProperty map[string]string }
func (*DisconnectProperty) ToProp ¶
func (d *DisconnectProperty) ToProp() *Property
type Encoder ¶
type Encoder interface { Duplicate() GetType() MessageType Encode() ([]byte, error) }
type Frame ¶
type Frame struct { Type MessageType DUP bool QoS QoSLevel RETAIN bool Size uint64 }
func (*Frame) GetType ¶
func (f *Frame) GetType() MessageType
type MessageType ¶
type MessageType uint8
const ( CONNECT MessageType CONNACK PUBLISH PUBACK PUBREC PUBREL PUBCOMP SUBSCRIBE SUBACK UNSUBSCRIBE UNSUBACK PINGREQ PINGRESP DISCONNECT AUTH )
func (MessageType) String ¶
func (i MessageType) String() string
type Property ¶
type Property struct { PayloadFormatIndicator uint8 MessageExpiryInterval uint32 ContentType string ResponseTopic string CorrelationData []byte SubscriptionIdentifier uint64 SessionExpiryInterval uint32 AssignedClientIdentifier string ServerKeepAlive uint16 AuthenticationMethod string AuthenticationData []byte RequestProblemInformation bool WillDelayInterval uint32 RequestResponseInformation bool ResponseInformation string ServerReference string ReasonString string ReceiveMaximum uint16 TopicAliasMaximum uint16 TopicAlias uint16 MaximumQoS uint8 RetainAvalilable bool UserProperty map[string]string MaximumPacketSize uint32 WildcardSubscriptionAvailable bool SubscrptionIdentifierAvailable bool }
func (*Property) ToAuth ¶
func (p *Property) ToAuth() *AuthProperty
func (*Property) ToConnAck ¶
func (p *Property) ToConnAck() *ConnAckProperty
func (*Property) ToConnect ¶
func (p *Property) ToConnect() *ConnectProperty
func (*Property) ToDisconnect ¶
func (p *Property) ToDisconnect() *DisconnectProperty
func (*Property) ToPubAck ¶
func (p *Property) ToPubAck() *PubAckProperty
func (*Property) ToPubComp ¶
func (p *Property) ToPubComp() *PubCompProperty
func (*Property) ToPubRec ¶
func (p *Property) ToPubRec() *PubRecProperty
func (*Property) ToPubRel ¶
func (p *Property) ToPubRel() *PubRelProperty
func (*Property) ToPublish ¶
func (p *Property) ToPublish() *PublishProperty
func (*Property) ToSubAck ¶
func (p *Property) ToSubAck() *SubAckProperty
func (*Property) ToSubscribe ¶
func (p *Property) ToSubscribe() *SubscribeProperty
func (*Property) ToUnsubAck ¶
func (p *Property) ToUnsubAck() *UnsubAckProperty
func (*Property) ToUnsubscribe ¶
func (p *Property) ToUnsubscribe() *UnsubscribeProperty
func (*Property) ToWill ¶
func (p *Property) ToWill() *WillProperty
type PropertyType ¶
type PropertyType uint8
const ( PayloadFormatIndicator PropertyType = 0x01 MessageExpiryInterval PropertyType = 0x02 ContentType PropertyType = 0x03 ResponseTopic PropertyType = 0x08 CorrelationData PropertyType = 0x09 SubscriptionIdentifier PropertyType = 0x0B SessionExpiryInterval PropertyType = 0x11 AssignedClientIdentifier PropertyType = 0x12 ServerKeepAlive PropertyType = 0x13 AuthenticationMethod PropertyType = 0x15 AuthenticationData PropertyType = 0x16 RequestProblemInformation PropertyType = 0x17 WillDelayInterval PropertyType = 0x18 RequestResponseInformation PropertyType = 0x19 ResponseInformation PropertyType = 0x1A ServerReference PropertyType = 0x1C ReasonString PropertyType = 0x1F ReceiveMaximum PropertyType = 0x21 TopicAliasMaximum PropertyType = 0x22 TopicAlias PropertyType = 0x23 MaximumQoS PropertyType = 0x24 RetainAvalilable PropertyType = 0x25 UserProperty PropertyType = 0x26 MaximumPacketSize PropertyType = 0x27 WildcardSubscriptionAvailable PropertyType = 0x28 SubscrptionIdentifierAvailable PropertyType = 0x29 )
func (PropertyType) Byte ¶
func (p PropertyType) Byte() byte
type PubAck ¶
type PubAck struct { *Frame PacketId uint16 ReasonCode ReasonCode Property *PubAckProperty }
type PubAckProperty ¶
func (*PubAckProperty) ToProp ¶
func (p *PubAckProperty) ToProp() *Property
type PubComp ¶
type PubComp struct { *Frame PacketId uint16 ReasonCode ReasonCode Property *PubCompProperty }
func NewPubComp ¶
type PubCompProperty ¶
func (*PubCompProperty) ToProp ¶
func (p *PubCompProperty) ToProp() *Property
type PubRec ¶
type PubRec struct { *Frame PacketId uint16 ReasonCode ReasonCode Property *PubRecProperty }
type PubRecProperty ¶
func (*PubRecProperty) ToProp ¶
func (p *PubRecProperty) ToProp() *Property
type PubRel ¶
type PubRel struct { *Frame PacketId uint16 ReasonCode ReasonCode Property *PubRelProperty }
type PubRelProperty ¶
func (*PubRelProperty) ToProp ¶
func (p *PubRelProperty) ToProp() *Property
type Publish ¶
type Publish struct { *Frame TopicName string PacketId uint16 Body []byte Property *PublishProperty }
func NewPublish ¶
type PublishProperty ¶
type PublishProperty struct { PayloadFormatIndicator uint8 MessageExpiryInterval uint32 ContentType string ResponseTopic string CorrelationData []byte SubscriptionIdentifier uint64 TopicAlias uint16 UserProperty map[string]string }
func (*PublishProperty) ToProp ¶
func (p *PublishProperty) ToProp() *Property
type ReasonCode ¶
type ReasonCode uint8
const ( Success ReasonCode = 0x00 NormalDisconnection ReasonCode = 0x00 GrantedQoS0 ReasonCode = 0x00 GrantedQoS1 ReasonCode = 0x01 GrantedQoS2 ReasonCode = 0x02 DisconnectWithWillMessage ReasonCode = 0x04 NoMatchingSubscribers ReasonCode = 0x10 NoSubscriptionExisted ReasonCode = 0x11 ContinueAuthentication ReasonCode = 0x18 ReAuthenticate ReasonCode = 0x19 UnspecifiedError ReasonCode = 0x80 MalformedPacket ReasonCode = 0x81 ProtocolError ReasonCode = 0x82 ImplementationSpecificError ReasonCode = 0x83 UnsupportedProtocolVersion ReasonCode = 0x84 ClientIdentifierNotValid ReasonCode = 0x85 BadUsernameOrPassword ReasonCode = 0x86 NotAuthorized ReasonCode = 0x87 ServerBusy ReasonCode = 0x89 Banned ReasonCode = 0x8A ServerShuttingDown ReasonCode = 0x8B BadAuthenticationMethod ReasonCode = 0x8C KeepAliveTimeout ReasonCode = 0x8D SessionTakenOver ReasonCode = 0x8E TopicFilterInvalid ReasonCode = 0x8F TopicNameInvalid ReasonCode = 0x90 PacketIdentifierInUse ReasonCode = 0x91 PacketIdentifierNotFound ReasonCode = 0x92 ReceiveMaximumExceeded ReasonCode = 0x93 TopicAliasInvalid ReasonCode = 0x94 PacketTooLarge ReasonCode = 0x95 MessageRateTooHigh ReasonCode = 0x96 QuotaExceeded ReasonCode = 0x97 AdministrativeAction ReasonCode = 0x98 PayloadFormatInvalid ReasonCode = 0x99 RetianlNotSupported ReasonCode = 0x9A QoSNotSupported ReasonCode = 0x9B UseAnotherServer ReasonCode = 0x9C ServerMoved ReasonCode = 0x9D ConnectionRateExceeded ReasonCode = 0x9F MaximumConnectionTime ReasonCode = 0xA0 SubscriptionIdentifiersNotSupported ReasonCode = 0xA1 WildcardSubscriptionsNotSupported ReasonCode = 0xA2 )
func (ReasonCode) Byte ¶
func (r ReasonCode) Byte() byte
func (ReasonCode) String ¶
func (i ReasonCode) String() string
type SubAck ¶
type SubAck struct { *Frame PacketId uint16 Property *SubAckProperty ReasonCodes []ReasonCode }
func NewSubAck ¶
func NewSubAck(packetId uint16, rcs ...ReasonCode) *SubAck
func (*SubAck) AddReasonCode ¶
func (s *SubAck) AddReasonCode(rcs ...ReasonCode)
type SubAckProperty ¶
func (*SubAckProperty) ToProp ¶
func (p *SubAckProperty) ToProp() *Property
type Subscribe ¶
type Subscribe struct { *Frame PacketId uint16 Property *SubscribeProperty Subscriptions []SubscribeTopic }
func NewSubscribe ¶
func NewSubscribe(opts ...option) *Subscribe
func (*Subscribe) AddTopic ¶
func (s *Subscribe) AddTopic(sts ...SubscribeTopic)
type SubscribeProperty ¶
func (*SubscribeProperty) ToProp ¶
func (s *SubscribeProperty) ToProp() *Property
type SubscribeTopic ¶
type UnsubAck ¶
type UnsubAck struct { *Frame PacketId uint16 Property *UnsubAckProperty ReasonCodes []ReasonCode }
func NewUnsubAck ¶
func NewUnsubAck(rcs ...ReasonCode) *UnsubAck
func (*UnsubAck) AddReasonCode ¶
func (u *UnsubAck) AddReasonCode(rcs ...ReasonCode)
type UnsubAckProperty ¶
func (*UnsubAckProperty) ToProp ¶
func (p *UnsubAckProperty) ToProp() *Property
type Unsubscribe ¶
type Unsubscribe struct { *Frame PacketId uint16 Topics []string Property *UnsubscribeProperty }
func NewUnsubscribe ¶
func NewUnsubscribe(opts ...option) *Unsubscribe
func ParseUnsubscribe ¶
func ParseUnsubscribe(f *Frame, p []byte) (u *Unsubscribe, err error)
func (*Unsubscribe) AddTopic ¶
func (u *Unsubscribe) AddTopic(topics ...string)
func (*Unsubscribe) Encode ¶
func (u *Unsubscribe) Encode() ([]byte, error)
func (*Unsubscribe) Validate ¶
func (u *Unsubscribe) Validate() error
type UnsubscribeProperty ¶
func (*UnsubscribeProperty) ToProp ¶
func (p *UnsubscribeProperty) ToProp() *Property
type WillProperty ¶
type WillProperty struct { PayloadFormatIndicator uint8 MessageExpiryInterval uint32 ContentType string ResponseTopic string CorrelationData []byte WillDelayInterval uint32 UserProperty map[string]string }
func (*WillProperty) ToProp ¶
func (w *WillProperty) ToProp() *Property
func (*WillProperty) ToPublish ¶
func (w *WillProperty) ToPublish() *PublishProperty
Source Files ¶
Click to show internal directories.
Click to hide internal directories.