topicsv5

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package topicsv5 Package topics deals with MQTT topic names, topic filters and subscriptions.

  • "Topic name" is a / separated string that could contain #, * and $
  • / in topic name separates the string into "topic levels"
  • # is a multi-level wildcard, and it must be the last character in the topic name. It represents the parent and all children levels.
  • + is a single level wildwcard. It must be the only character in the topic level. It represents all names in the current level.
  • $ is a special character that says the topic is a system level topic

Index

Constants

View Source
const (
	// MWC is the multi-level wildcard
	MWC = "#"

	// SWC is the single level wildcard
	SWC = "+"

	// SEP is the topic level separator
	SEP = "/"

	// SYS is the starting character of the system level topics
	//SYS是系统级主题的起始字符
	SYS = "$"
)

Variables

View Source
var (
	// ErrAuthFailure is returned when the user/pass supplied are invalid
	ErrAuthFailure = errors.New("auth: Authentication failure")

	// ErrAuthProviderNotFound is returned when the requested provider does not exist.
	// It probably hasn't been registered yet.
	ErrAuthProviderNotFound = errors.New("auth: Authentication provider not found")
)
View Source
var Default = "default"

Functions

func InitTopic

func InitTopic(client *gorm.DB)

func Register

func Register(name string, provider TopicsProvider)

func TopicInit

func TopicInit(topicPro string)

func Unregister

func Unregister(name string)

Types

type Manager

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

func NewManager

func NewManager(providerName string) (*Manager, error)

func (*Manager) AllSubInfo

func (this *Manager) AllSubInfo() (map[string][]string, error)

func (*Manager) Close

func (this *Manager) Close() error

func (*Manager) Retain

func (this *Manager) Retain(msg *messagev5.PublishMessage) error

func (*Manager) Retained

func (this *Manager) Retained(topic []byte, msgs *[]*messagev5.PublishMessage) error

func (*Manager) Subscribe

func (this *Manager) Subscribe(topic []byte, qos byte, subscriber interface{}) (byte, error)

func (*Manager) Subscribers

func (this *Manager) Subscribers(topic []byte, qos byte, subs *[]interface{}, qoss *[]byte, svc bool, shareName string, onlyShare bool) error

if shareName == "" && onlyShare == false ===>> 表示不需要获取任何共享主题订阅者,只需要所有非共享组的订阅者们 if shareName == "" && onlyShare == true ===>> 表示获取当前主题shareName的所有共享组每个的组的一个订阅者,不需要所有非共享组的订阅者们 if onlyShare == false && shareName != "" ===>> 获取当前主题的共享组名为shareName的订阅者一个与所有非共享组订阅者们 if onlyShare == true && shareName != "" ===>> 仅仅获取主题的共享组名为shareName的订阅者一个

func (*Manager) Unsubscribe

func (this *Manager) Unsubscribe(topic []byte, subscriber interface{}) error

type TopicsProvider

type TopicsProvider interface {
	Subscribe(topic []byte, qos byte, subscriber interface{}) (byte, error)
	Unsubscribe(topic []byte, subscriber interface{}) error

	// if shareName == "" && onlyShare == false ===>> 表示不需要获取任何共享主题订阅者,只需要所有非共享组的订阅者们
	// if shareName == "" && onlyShare == true  ===>> 表示获取当前主题shareName的所有共享组每个的组的一个订阅者,不需要所有非共享组的订阅者们
	// if onlyShare == false && shareName != "" ===>> 获取当前主题的共享组名为shareName的订阅者一个与所有非共享组订阅者们
	// if onlyShare == true && shareName != ""  ===>> 仅仅获取主题的共享组名为shareName的订阅者一个
	Subscribers(topic []byte, qos byte, subs *[]interface{}, qoss *[]byte, svc bool, shareName string, onlyShare bool) error
	AllSubInfo() (map[string][]string, error) // 获取所有的共享订阅,k: 主题,v: 该主题的所有共享组
	Retain(msg *messagev5.PublishMessage) error
	Retained(topic []byte, msgs *[]*messagev5.PublishMessage) error
	Close() error
}

TopicsProvider

Directories

Path Synopsis
共享订阅 共享订阅 共享订阅
共享订阅 共享订阅 共享订阅
共享订阅 系统主题 共享订阅
共享订阅 系统主题 共享订阅

Jump to

Keyboard shortcuts

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