mqtt

package
v2.0.437+incompatible Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: AGPL-3.0 Imports: 5 Imported by: 6

Documentation

Index

Constants

View Source
const (
	TypeOfConnect = uint8(iota + 1)
	TypeOfConnack
	TypeOfPublish
	TypeOfPuback
	TypeOfPubrec
	TypeOfPubrel
	TypeOfPubcomp
	TypeOfSubscribe
	TypeOfSuback
	TypeOfUnsubscribe
	TypeOfUnsuback
	TypeOfPingreq
	TypeOfPingresp
	TypeOfDisconnect
)

MQTT message types

Variables

This section is empty.

Functions

This section is empty.

Types

type Connack

type Connack struct {
	ReturnCode uint8
}

Connack represents an MQTT connack packet. 0x00 connection accepted 0x01 refused: unacceptable proto version 0x02 refused: identifier rejected 0x03 refused server unavailiable 0x04 bad user or password 0x05 not authorized

func (*Connack) EncodeTo

func (c *Connack) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Connack) Type

func (c *Connack) Type() uint8

Type returns the MQTT message type.

type Connect

type Connect struct {
	ProtoName      []byte
	Version        uint8
	UsernameFlag   bool
	PasswordFlag   bool
	WillRetainFlag bool
	WillQOS        uint8
	WillFlag       bool
	CleanSeshFlag  bool
	KeepAlive      uint16
	ClientID       []byte
	WillTopic      []byte
	WillMessage    []byte
	Username       []byte
	Password       []byte
}

Connect represents an MQTT connect packet.

func (*Connect) EncodeTo

func (c *Connect) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Connect) Type

func (c *Connect) Type() uint8

Type returns the MQTT message type.

type Disconnect

type Disconnect struct {
}

Disconnect is to signal you want to cease communications with the server

func (*Disconnect) EncodeTo

func (d *Disconnect) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Disconnect) Type

func (d *Disconnect) Type() uint8

Type returns the MQTT message type.

type Message

type Message interface {
	Type() uint8
	EncodeTo(w io.Writer) (int, error)
}

Message is the interface all our packets will be implementing

func DecodePacket

func DecodePacket(rdr io.Reader) (Message, error)

DecodePacket decodes the packet from the provided reader.

type Pingreq

type Pingreq struct {
}

Pingreq is a keepalive

func (*Pingreq) EncodeTo

func (p *Pingreq) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Pingreq) Type

func (p *Pingreq) Type() uint8

Type returns the MQTT message type.

type Pingresp

type Pingresp struct {
}

Pingresp is for saying "hey, the server is alive"

func (*Pingresp) EncodeTo

func (p *Pingresp) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Pingresp) Type

func (p *Pingresp) Type() uint8

Type returns the MQTT message type.

type Puback

type Puback struct {
	MessageID uint16
}

Puback is sent for QOS level one to verify the receipt of a publish Qoth the spec: "A PUBACK message is sent by a server in response to a PUBLISH message from a publishing client, and by a subscriber in response to a PUBLISH message from the server."

func (*Puback) EncodeTo

func (p *Puback) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Puback) Type

func (p *Puback) Type() uint8

Type returns the MQTT message type.

type Pubcomp

type Pubcomp struct {
	MessageID uint16
}

Pubcomp is for saying is in response to a pubrel sent by the publisher the final member of the QOS2 flow. both sides have said "hey, we did it!"

func (*Pubcomp) EncodeTo

func (p *Pubcomp) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Pubcomp) Type

func (p *Pubcomp) Type() uint8

Type returns the MQTT message type.

type Publish

type Publish struct {
	Header    *StaticHeader
	Topic     []byte
	MessageID uint16
	Payload   []byte
}

Publish represents an MQTT publish packet.

func (*Publish) EncodeTo

func (p *Publish) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Publish) Type

func (p *Publish) Type() uint8

Type returns the MQTT message type.

type Pubrec

type Pubrec struct {
	MessageID uint16
}

Pubrec is for verifying the receipt of a publish Qoth the spec:"It is the second message of the QoS level 2 protocol flow. A PUBREC message is sent by the server in response to a PUBLISH message from a publishing client, or by a subscriber in response to a PUBLISH message from the server."

func (*Pubrec) EncodeTo

func (p *Pubrec) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Pubrec) Type

func (p *Pubrec) Type() uint8

Type returns the MQTT message type.

type Pubrel

type Pubrel struct {
	MessageID uint16
	//QOS1
	Header *StaticHeader
}

Pubrel is a response to pubrec from either the client or server.

func (*Pubrel) EncodeTo

func (p *Pubrel) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Pubrel) Type

func (p *Pubrel) Type() uint8

Type returns the MQTT message type.

type StaticHeader

type StaticHeader struct {
	DUP    bool
	Retain bool
	QOS    uint8
}

StaticHeader as defined in http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html#fixed-header

type Suback

type Suback struct {
	MessageID uint16
	Qos       []uint8
}

Suback is to say "hey, you got it buddy. I will send you messages that fit this pattern"

func (*Suback) EncodeTo

func (s *Suback) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Suback) Type

func (s *Suback) Type() uint8

Type returns the MQTT message type.

type Subscribe

type Subscribe struct {
	Header        *StaticHeader
	MessageID     uint16
	Subscriptions []TopicQOSTuple
}

Subscribe tells the server which topics the client would like to subscribe to

func (*Subscribe) EncodeTo

func (s *Subscribe) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Subscribe) Type

func (s *Subscribe) Type() uint8

Type returns the MQTT message type.

type TopicQOSTuple

type TopicQOSTuple struct {
	Qos   uint8
	Topic []byte
}

TopicQOSTuple is a struct for pairing the Qos and topic together for the QOS' pairs in unsubscribe and subscribe

type Unsuback

type Unsuback struct {
	MessageID uint16
}

Unsuback is to unsubscribe as suback is to subscribe

func (*Unsuback) EncodeTo

func (u *Unsuback) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Unsuback) Type

func (u *Unsuback) Type() uint8

Type returns the MQTT message type.

type Unsubscribe

type Unsubscribe struct {
	Header    *StaticHeader
	MessageID uint16
	Topics    []TopicQOSTuple
}

Unsubscribe is the message to send if you don't want to subscribe to a topic anymore

func (*Unsubscribe) EncodeTo

func (u *Unsubscribe) EncodeTo(w io.Writer) (int, error)

EncodeTo writes the encoded message to the underlying writer.

func (*Unsubscribe) Type

func (u *Unsubscribe) Type() uint8

Type returns the MQTT message type.

Jump to

Keyboard shortcuts

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