Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ConnAck status codes ConnAckAccepted uint8 = 0x00 ConnAckBadVersion uint8 = 0x01 ConnAckIDNotAllowed uint8 = 0x02 ConnAckBadCredentials uint8 = 0x04 )
View Source
const ( // Flags PublishFlagDuplicate uint8 = 0x08 PublishFlagRetain uint8 = 0x01 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnAck ¶
func (*ConnAck) MarshalBinary ¶
type Connect ¶
type Connect struct { // Version holds the protocol version of this packet (see mqtt package). Version mqtt.Version // CleanSession stores the clean session flag (MQTT 3.1.1) or clean // start flag (MQTT 5.0). // // For MQTT 3.1.1 the clean session flag forces the server to discard // any previous session state and start a new one which last until the // client disconnects. // // For MQTT 5.0 however, the clean start flag only notifies the server // to discard session state on connect. What happens after disconnect // is determined by session expiry interval. CleanSession bool // KeepAlive contains the duration in seconds for the client to remain // inactive before getting disconnected. KeepAlive uint16 // WillTopic is an optional topic to publish on a successful connect. WillTopic mqtt.Topic // WillMessage is the payload message for the WillTopic (max 64KiB). // NOTE: WillMessage requires WillTopic to be set, otherwise the // parameter is ignored. WillMessage []byte // WillRetain holds the retain flag for the published WillTopic. If // set to true, the server retains the message for future subscribers // on the WillTopic. WillRetain bool // ClientID stores the client identifier presented to the server. If // left empty a random UUID (v4) is automatically generated. ClientID string // Username holds the Username credential if the server has access // control enabled (cannot be an empty string). Username string // Password stores the password credential (cannot be an empty string). // NOTE: (MQTTv311) Password requires username to be assigned, // otherwise the parameter is ignored. Password string // SessionExpiryInterval holds the duration in seconds the server is // required to store the session state. A value of 0xFFFFFFFF // (max(uint32)) makes the session does not expire. If the value 0 is // used, the session expire when the network connection is closed // (defaults to 0). SessionExpiryInterval uint32 // MaxPacketSize tells the server the maximum packet size the client // is willing to accept (defaults to 0: no limit). MaxPacketSize uint32 // ReceiveMax notifies the server about the number of QOS1 and QOS2 // publish packets the client is willing to process simultaneously // (defaults to 65535). ReceiveMax uint16 // TopicAliasMax sets the limit on the highest number of topic aliases // the client is willing to accept from the server (defaults to 0). TopicAliasMax uint16 // RequestResponseInfo requests the server to return response // information in the ConnAck packet. (defaults to false). RequestResponseInfo bool // DisableProblemInfo requests the server NOT to return a reason string // or user properties on Publish, ConnAck and Disconnect packet // (defaults to false: enabled). DisableProblemInfo bool // ConnUserProperties contains user specified (connection related) // key-value pairs. The meaning of these properties is not defined by // the MQTT 5.0 specification // (ref. https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.pdf :871). ConnUserProperties map[string]string // AuthMethod specifies (and enables) the name of the authentication // method used for extensive authentication. If specified, the client // must not follow up with any other packets than Auth or Disconnect // packets until a ConnAck is received. (defaults to none/disabled). AuthMethod string // AuthData holds binary data associated with the specified AuthMethod. // If an AuthMethod is not specified this parameter is ignored. AuthData []byte // WillDelayInterval requests the server to delay publishing the // WillMessage after the set amount of seconds (defaults to 0). WillDelayInterval uint32 // WillMessageExpiry sets the expiry interval for the published // WillMessage (defaults to 0: unset). WillMessageExpiry uint32 // WillFormatUTF8 notifies the server that the WillMessage is encoded // using UTF8, otherwise the payload is treated as a stream of bytes // (default). WillFormatUTF8 bool // WillContentType provides a string content-type descriptor of the // published WillMessage (unset by default). WillContentType string // WillResponseTopic provides a response topic the recipients should // use to respond to the WillMessage. Setting the WillResponseTopic // enables request/response interaction between MQTT clients. (defaults // to none). WillResponseTopic string // WillCorrelationData is used by the sender of the request message to // identify which request the response message is for. The value is // ignored if WillResponseTopic is not set (defaults to unset). WillCorrelationData []byte // WillUserProperties provides user-specified key:value pairs of data // to the WillMessage. The interpretation of these parameters are // completely up to the user's application (think of it as custom HTTP // headers). WillUserProperties map[string]string }
Connect contains a structural representation of a connect packet. Some of the parameters are dependent, for instance: Password requires Username to be set. Other parameters are version dependent, these are highlighted in the parameter description.
func (*Connect) MarshalBinary ¶
type Disconnect ¶
func (*Disconnect) MarshalBinary ¶
func (d *Disconnect) MarshalBinary() (b []byte, err error)
type Packet ¶
type Packet interface { // WriteTo serializes the packet and writes it to the given writer // returning the number of bytes written. WriteTo(w io.Writer) (n int64, err error) // ReadFrom reads and unmarshals the packet from the given stream // returning the number of bytes read. ReadFrom(r io.Reader) (n int64, err error) // MarshalBinary serializes the packet to a binary buffer. MarshalBinary() (b []byte, err error) }
Packet contains a generic packet interface conforming with the standard io WriteTo/ReadFrom definitions.
type PacketIO ¶
type PacketIO struct {
// contains filtered or unexported fields
}
PacketIO provides an interface for communicating packets between client and server.
func NewPacketIO ¶
NewPacketIO initializes a new PacketIO struct.
type PingReq ¶
func (*PingReq) MarshalBinary ¶
type PingResp ¶
func (*PingResp) MarshalBinary ¶
type PubAck ¶
func (*PubAck) MarshalBinary ¶
type PubComp ¶
func (*PubComp) MarshalBinary ¶
type PubRec ¶
func (*PubRec) MarshalBinary ¶
type PubRel ¶
func (*PubRel) MarshalBinary ¶
type Publish ¶
type Publish struct { mqtt.Topic Version mqtt.Version // Flags Duplicate bool Retain bool // Variable header PacketIdentifier uint16 Payload []byte }
func (*Publish) MarshalBinary ¶
type SubAck ¶
func (*SubAck) MarshalBinary ¶
type Subscribe ¶
type Subscribe struct { Version mqtt.Version PacketIdentifier uint16 // Payload Topics []mqtt.Topic }
func (*Subscribe) MarshalBinary ¶
type UnsubAck ¶
func (*UnsubAck) MarshalBinary ¶
type Unsubscribe ¶
func (*Unsubscribe) MarshalBinary ¶
func (u *Unsubscribe) MarshalBinary() (b []byte, err error)
Click to show internal directories.
Click to hide internal directories.