mqtt

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetTopic(string) (*Topic, bool)
	IsConnected() bool
	Subscribe(string) *Topic
	Unsubscribe(string)
	Dispose()
}

func NewClient

func NewClient(o Options) (Client, error)

type Message

type Message struct {
	Timestamp time.Time
	Value     []byte
}

type Options

type Options struct {
	URI      string `json:"uri"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type Topic

type Topic struct {
	Path     string `json:"topic"`
	Interval time.Duration
	Messages []Message
	// contains filtered or unexported fields
}

Topic represents a MQTT topic.

func (*Topic) Key

func (t *Topic) Key() string

Key returns the key for the topic. The key is a combination of the interval string and the path. For example, if the path is "my/topic" and the interval is 1s, the key will be "1s/my/topic".

func (*Topic) ToDataFrame

func (t *Topic) ToDataFrame() (*data.Frame, error)

ToDataFrame converts the topic to a data frame.

type TopicMap

type TopicMap struct {
	sync.Map
}

TopicMap is a thread-safe map of topics

func (*TopicMap) AddMessage

func (tm *TopicMap) AddMessage(path string, message Message)

AddMessage adds a message to the topic for the given path.

func (*TopicMap) Delete

func (tm *TopicMap) Delete(key string)

Delete deletes the topic for the given key.

func (*TopicMap) HasSubscription

func (tm *TopicMap) HasSubscription(path string) bool

HasSubscription returns true if the topic map has a subscription for the given path.

func (*TopicMap) Load

func (tm *TopicMap) Load(key string) (*Topic, bool)

Load returns the topic for the given topic key.

func (*TopicMap) Store

func (tm *TopicMap) Store(t *Topic)

Store stores the topic in the map.

Jump to

Keyboard shortcuts

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