mqtt

package
v1.9.7 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONNECT   = 0x10
	CONNACK   = 0x20
	PUBLISH   = 0x30
	PUBACK    = 0x40
	SUBSCRIBE = 0x82
	SUBACK    = 0x90
	QOS1      = 0x02
)

https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html

View Source
const Timeout = time.Second * 5

Variables

This section is empty.

Functions

func ReadLen

func ReadLen(r io.Reader) (uint32, error)

Types

type Client

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

func NewClient

func NewClient(conn net.Conn) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect(clientID, username, password string) (err error)

func (*Client) Publish

func (c *Client) Publish(topic string, payload []byte) (err error)

func (*Client) Read

func (c *Client) Read() (string, []byte, error)

func (*Client) Subscribe

func (c *Client) Subscribe(topic string) (err error)

type Message

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

func NewConnect

func NewConnect(clientID, username, password string) *Message

func NewPublish

func NewPublish(topic string, payload []byte) *Message

func NewPublishQOS1

func NewPublishQOS1(mid uint16, topic string, payload []byte) *Message

func NewSubscribe

func NewSubscribe(mid uint16, topic string, qos byte) *Message

func (*Message) Bytes

func (m *Message) Bytes() []byte

func (*Message) WriteByte

func (m *Message) WriteByte(b byte)

func (*Message) WriteBytes

func (m *Message) WriteBytes(b []byte)

func (*Message) WriteLen

func (m *Message) WriteLen(i int)

func (*Message) WriteString

func (m *Message) WriteString(s string)

func (*Message) WriteUint16

func (m *Message) WriteUint16(i uint16)

Jump to

Keyboard shortcuts

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