emqx

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectHandler

type ConnectHandler func(mqtt.Client)

type ConnectLostHandler

type ConnectLostHandler func(mqtt.Client, error)

type Context

type Context struct {
	context.Context
	Client  mqtt.Client
	Message mqtt.Message
	URI     string
	Topic   string
	Buffer  []byte
	Body    string
}

func NewContext

func NewContext(client mqtt.Client, msg mqtt.Message, path []string) *Context

NewContext 创建上下文

type Engine

type Engine struct {
	*Options
	Topic      string
	TopicLen   int
	Wildcard   bool
	Shared     bool
	ShareGroup string

	BeforeHook []HookHandler
	AfterHook  []HookHandler
	// contains filtered or unexported fields
}

func (*Engine) Register

func (e *Engine) Register(url string, handler HandlerFunc)

Register 注册方法到前缀树

func (*Engine) UseAfter

func (e *Engine) UseAfter(handler ...HookHandler)

func (*Engine) UseBefore

func (e *Engine) UseBefore(handler ...HookHandler)

func (*Engine) WithShare added in v1.2.0

func (e *Engine) WithShare(group string)

WithShare 注册共享订阅

type HandlerFunc

type HandlerFunc func(*Context)

type HookHandler

type HookHandler func(*Context)

type MQTT

type MQTT struct {
	*Options
	// contains filtered or unexported fields
}

func GetConnect

func GetConnect() *MQTT

func InitClient

func InitClient(opt *Options) *MQTT

func (*MQTT) Connect

func (m *MQTT) Connect() error

func (*MQTT) Publish

func (m *MQTT) Publish(topic string, data []byte) error

func (*MQTT) PublishShare added in v1.2.0

func (m *MQTT) PublishShare(topic string, data []byte, group string) error

PublishShare 发布共享消息

type Options

type Options struct {
	Addr               string
	ID                 string
	Username           string
	Password           string
	KeepAlive          time.Duration
	SetPingTimeout     time.Duration
	Engine             []*Engine
	ConnectHandler     ConnectHandler
	ConnectLostHandler ConnectLostHandler
	Logger             logger.Interface
}

Options 默认配置 本组件放弃维护,建议使用emq5工具包 Deprecated

func Default

func Default(addr, id, username, password string) *Options

func (*Options) NewEngine

func (o *Options) NewEngine(topic string, wildcard bool) (eng *Engine)

type PublishHook

type PublishHook func()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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