mqtt

package
Version: v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: Apache-2.0 Imports: 12 Imported by: 9

Documentation

Index

Constants

View Source
const (
	Rserved = iota
	CONNECT //1
	CONNACK //2

	PUBLISH //3
	PUBACK  //4
	PUBREC  //5
	PUBREL  //6
	PUBCOMP //7

	SUBSCRIBE //8
	SUBACK    //9

	UNSUBSCRIBE //10
	UNSUBACK    //11

	PINGREQ  //12
	PINGRESP //13

	DISCONNECT //14
)
View Source
const (
	NO_DELAY = iota
	DELAY
	FLUSH

	DISCONNECTED = iota
	CONNECTED
	CLOSED
	RECONNECTING
	CONNECTING
)

1 is delay, 0 is no delay, 2 is just flush.

Variables

This section is empty.

Functions

func DelayWritePack

func DelayWritePack(pack *Pack, w *bufio.Writer) (err error)

func WritePack

func WritePack(pack *Pack, w *bufio.Writer) error

Types

type Client

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

func NewClient

func NewClient(conf conf.Mqtt, recover PackRecover, r *bufio.Reader, w *bufio.Writer, conn network.Conn, alive int) *Client

func (*Client) Listen_loop

func (c *Client) Listen_loop() (e error)

Push the msg and response the heart beat

func (*Client) WriteMsg

func (c *Client) WriteMsg(topic string, body []byte) error

type Connack

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

func (*Connack) GetReturnCode

func (c *Connack) GetReturnCode() byte

func (*Connack) SetReturnCode

func (c *Connack) SetReturnCode(return_code byte)

type Connect

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

func (*Connect) GetKeepAlive

func (c *Connect) GetKeepAlive() int

func (*Connect) GetPassword

func (c *Connect) GetPassword() *string

func (*Connect) GetProtocol

func (c *Connect) GetProtocol() *string

func (*Connect) GetReturnCode

func (c *Connect) GetReturnCode() byte

func (*Connect) GetUserName

func (c *Connect) GetUserName() *string

func (*Connect) GetVersion

func (c *Connect) GetVersion() byte

func (*Connect) GetWillMsg

func (c *Connect) GetWillMsg() (bool, *string, *string)

func (*Connect) IsCleanSession

func (c *Connect) IsCleanSession() bool

type Pack

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

func GetConnAckPack

func GetConnAckPack(return_code byte) *Pack

Get a connection ack pack

func GetPingResp

func GetPingResp(qos byte, dup byte) *Pack

Get a request for ping pack

func GetPubAckPack

func GetPubAckPack(mid int) *Pack

Get a connection ack pack

func GetPubCOMPPack

func GetPubCOMPPack(mid int) *Pack

Get a connection ack pack

func GetPubPack

func GetPubPack(qos byte, dup byte, mid int, topic *string, msg []byte) *Pack

Get a publis pack

func GetPubRECPack

func GetPubRECPack(mid int) *Pack

Get a connection ack pack

func GetPubRELPack

func GetPubRELPack(mid int) *Pack

Get a connection ack pack

func GetSubAckPack

func GetSubAckPack(mid int) *Pack

Get a connection ack pack

func GetUNSubAckPack

func GetUNSubAckPack(mid int) *Pack

func ReadPack

func ReadPack(r *bufio.Reader) (pack *Pack, err error)

Read and Write a mqtt pack

func (*Pack) GetDup

func (pack *Pack) GetDup() byte

func (*Pack) GetQos

func (pack *Pack) GetQos() byte

func (*Pack) GetType

func (pack *Pack) GetType() byte

func (*Pack) GetVariable

func (pack *Pack) GetVariable() interface{}

func (*Pack) SetDup

func (pack *Pack) SetDup(dup byte)

func (*Pack) SetQos

func (pack *Pack) SetQos(qos byte)

func (*Pack) SetType

func (pack *Pack) SetType(typ byte)

type PackQueue

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

Tcp write queue

func NewPackQueue

func NewPackQueue(conf conf.Mqtt, r *bufio.Reader, w *bufio.Writer, conn network.Conn, recover func(pAndErr *packAndErr) (err error), alive int) *PackQueue

Init a pack queue

func (*PackQueue) Close

func (queue *PackQueue) Close(err error) error

Close the all of queue's channels

func (*PackQueue) Flusher

func (queue *PackQueue) Flusher()

Get a read pack queue Only call once

func (*PackQueue) ReadPackInLoop

func (queue *PackQueue) ReadPackInLoop()

Get a read pack queue Only call once

func (*PackQueue) SetAlive

func (queue *PackQueue) SetAlive(alive int) error

func (*PackQueue) WritePack

func (queue *PackQueue) WritePack(pack *Pack) (err error)

Write a pack , and get the last error

type PackRecover

type PackRecover interface {
	OnRecover(*Pack)
}

type Puback

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

func (*Puback) GetMid

func (ack *Puback) GetMid() int

func (*Puback) SetMid

func (ack *Puback) SetMid(id int)

type Publish

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

func (*Publish) GetMid

func (pub *Publish) GetMid() int

func (*Publish) GetMsg

func (pub *Publish) GetMsg() []byte

func (*Publish) GetTopic

func (pub *Publish) GetTopic() *string

func (*Publish) SetMid

func (pub *Publish) SetMid(id int)

func (*Publish) SetMsg

func (pub *Publish) SetMsg(msg []byte)

func (*Publish) SetTopic

func (pub *Publish) SetTopic(topic *string)

type Suback

type Suback struct {
	Qos byte //0  2
	// contains filtered or unexported fields
}

type Subscribe

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

func (*Subscribe) GetMid

func (sub *Subscribe) GetMid() int

func (*Subscribe) GetTopics

func (sub *Subscribe) GetTopics() []Topics

func (*Subscribe) SetMid

func (sub *Subscribe) SetMid(id int)

type Topics

type Topics struct {
	Qos byte
	// contains filtered or unexported fields
}

func (*Topics) GetName

func (top *Topics) GetName() *string

func (*Topics) GetQos

func (top *Topics) GetQos() byte

func (*Topics) SetQos

func (top *Topics) SetQos(Qos byte)

type UNSuback

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

type UNSubscribe

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

func (*UNSubscribe) GetMid

func (sub *UNSubscribe) GetMid() int

func (*UNSubscribe) GetTopics

func (sub *UNSubscribe) GetTopics() []Topics

func (*UNSubscribe) SetMid

func (sub *UNSubscribe) SetMid(id int)

type UNTopics

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

func (*UNTopics) GetName

func (top *UNTopics) GetName() *string

Jump to

Keyboard shortcuts

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