packets

package
v0.0.0-...-a833e92 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONNECT = 1 // CONNECT packet does not include any flags in the packet type
	CONNACK = 2 // CONNECT ACKNOWLEDGEMENT packet does not include any flags in the packet type

	PUBLISH = 3 // PUBLISH packet without any flags
	PUBACK  = 4 // PUBLISH ACKNOWLEDGMENT packet

	SUBSCRIBE = 8 // SUBSCRIBE packet without any flags
	SUBACK    = 9 // SUBSCRIBE ACKNOWLEDGMENT packet

	PINGREQ  = 12 // PING_REQ packet without any flags
	PINGRESP = 13 // PING_RESP packet without any flags
)
View Source
const (
	DUP    = 0x08
	RETAIN = 0x01
)

Variables

This section is empty.

Functions

func CreateConnectFlagByte

func CreateConnectFlagByte(flags ConnectFlags) uint8

Types

type ConnACKPacket

type ConnACKPacket struct {
	Packet byte
}

func (*ConnACKPacket) Compress

func (p *ConnACKPacket) Compress() byte

func (*ConnACKPacket) Decompress

func (p *ConnACKPacket) Decompress(packetByte byte) error

type ConnectFlags

type ConnectFlags struct {
	Username     bool
	Password     bool
	Retain       bool
	QoS          uint8 // 0, 1, 2, or 3
	CleanSession bool
}

type ConnectPacket

type ConnectPacket struct {
	Packet byte
}

func (*ConnectPacket) Compress

func (p *ConnectPacket) Compress() byte

func (*ConnectPacket) Decompress

func (p *ConnectPacket) Decompress(packetByte byte) error

type Packet

type Packet interface {
	Compress() byte
	Decompress(packetByte byte) error
}

type PublishPacket

type PublishPacket struct {
	DUP        uint8 // duplicate delivery flag (bit 3) - this is 1 or 0, 1 = is re-delivery/duplicate of message
	QOSLevel   QoS   // quality of service level (bit 2 & 1)
	RetainFlag uint8 // retain flag (bit 0) - if set to 1, the message should be retained by the broker and delivered to future subscribers with a matching subscription
	// contains filtered or unexported fields
}

00110010 0011 0010

func (*PublishPacket) Compress

func (p *PublishPacket) Compress() byte

func (*PublishPacket) Decompress

func (p *PublishPacket) Decompress(packetByte byte) error

func (*PublishPacket) GetPacketType

func (p *PublishPacket) GetPacketType() uint8

type QoS

type QoS uint8
const (
	QOS_LEVEL_0 QoS = 0x00
	QOS_LEVEL_1 QoS = 0x01
	QOS_LEVEL_2 QoS = 0x02
)

func (QoS) IsEnum

func (q QoS) IsEnum()

type SubscribePacket

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

func (*SubscribePacket) Compress

func (sp *SubscribePacket) Compress() byte

func (*SubscribePacket) Decompress

func (sp *SubscribePacket) Decompress(packetByte byte) error

func (*SubscribePacket) GetPacketType

func (sp *SubscribePacket) GetPacketType() uint8

Jump to

Keyboard shortcuts

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