Documentation ¶
Overview ¶
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
- Variables
- func NewMemProvider() *memTopics
- func Register(name string, provider TopicsProvider)
- func Unregister(name string)
- type Manager
- func (this *Manager) Close() error
- func (this *Manager) Retain(msg *message.PublishMessage, profile interface{}) error
- func (this *Manager) Retained(topic []byte, msgs *[]*message.PublishMessage, profile interface{}) error
- func (this *Manager) Subscribe(topic []byte, qos byte, subscriber Subscriber, profile interface{}) (byte, error)
- func (this *Manager) Subscribers(topic []byte, qos byte, subs *[]Subscriber, qoss *[]byte, profile interface{}) error
- func (this *Manager) Unsubscribe(topic []byte, subscriber Subscriber, profile interface{}) error
- type Subscriber
- type TopicsProvider
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 = "$" )
Variables ¶
View Source
var ( // MaxQosAllowed is the maximum QOS supported by this server MaxQosAllowed = message.QosExactlyOnce )
Functions ¶
func NewMemProvider ¶
func NewMemProvider() *memTopics
NewMemProvider returns an new instance of the memTopics, which is implements the TopicsProvider interface. memProvider is a hidden struct that stores the topic subscriptions and retained messages in memory. The content is not persistend so when the server goes, everything will be gone. Use with care.
func Register ¶
func Register(name string, provider TopicsProvider)
func Unregister ¶
func Unregister(name string)
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) Retain ¶
func (this *Manager) Retain(msg *message.PublishMessage, profile interface{}) error
func (*Manager) Retained ¶
func (this *Manager) Retained(topic []byte, msgs *[]*message.PublishMessage, profile interface{}) error
func (*Manager) Subscribers ¶
func (*Manager) Unsubscribe ¶
func (this *Manager) Unsubscribe(topic []byte, subscriber Subscriber, profile interface{}) error
type Subscriber ¶
type Subscriber interface {
OnPublish(msg *message.PublishMessage) error
}
type TopicsProvider ¶
type TopicsProvider interface { Subscribe(topic []byte, qos byte, subscriber Subscriber, profile interface{}) (byte, error) Unsubscribe(topic []byte, subscriber Subscriber, profile interface{}) error Subscribers(topic []byte, qos byte, subs *[]Subscriber, qoss *[]byte, profile interface{}) error Retain(msg *message.PublishMessage, profile interface{}) error Retained(topic []byte, msgs *[]*message.PublishMessage, profile interface{}) error Close() error }
TopicsProvider
Click to show internal directories.
Click to hide internal directories.