mqtt_client

package
v1.1.0-alpha7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMessageIgnore = errors.New("mqtt消息忽略")
)

Functions

func Destroy

func Destroy(client *Client)

Types

type Client

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

func New

func New(opts *ClientOptions) (*Client, error)

func (*Client) Publish

func (client *Client) Publish(topic string, qos byte, retained bool, payload any) error

func (*Client) PublishAndReceiveReply

func (client *Client) PublishAndReceiveReply(params *PublishAndReceiveReplyParams, payloadDealFunc func(payload []byte) error) error

func (*Client) PublishAndReceiveReplyMsgResponse

func (client *Client) PublishAndReceiveReplyMsgResponse(params *PublishAndReceiveReplyParams) error

func (*Client) Subscribe

func (client *Client) Subscribe(topic string, handlerFunc MessageHandler) (*SubscribeToken, error)

func (*Client) Unsubscribe

func (client *Client) Unsubscribe(topic string, token *SubscribeToken) error

type ClientOptions

type ClientOptions struct {
	UserName        string
	Password        string
	Address         string
	ClientID        string
	KeepAliveSec    int64
	PingTimeoutSec  int64
	WriteTimeoutSec int64
}

type MessageHandler

type MessageHandler func(client *Client, token *SubscribeToken, topic string, data []byte) error

type PublishAndReceiveReplyParams

type PublishAndReceiveReplyParams struct {
	Topic                string
	ReplyTopic           string
	PublishData          []byte
	RepublishDurationSec int64
	TryTimes             int
	StopBefore           bool
}

func (*PublishAndReceiveReplyParams) Check

func (params *PublishAndReceiveReplyParams) Check() error

type SubscribeToken

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

func (*SubscribeToken) HandleCount

func (token *SubscribeToken) HandleCount() int

func (*SubscribeToken) SuccessHandleCount

func (token *SubscribeToken) SuccessHandleCount() int

Jump to

Keyboard shortcuts

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