mqtt

package
v0.0.0-...-91e7bcc Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr string

	SessionQueueSize   int
	ParallelPublishes  int
	ParallelSubscribes int
	InflightMessages   int
	TokenTimeoutSec    int64
}

Config is a MQTT service configuration.

type Service

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

Service represents MQTT broker and client for handling device connection.

func New

func New(conf Config) (*Service, error)

New create new instance of MQTT service implementation.

func (*Service) ActiveHandler

func (s *Service) ActiveHandler(fn func(string))

ActiveHandler callback triggers when device is connected and responded on ping.

func (*Service) Close

func (s *Service) Close() error

Close closes all connections created by service.

func (*Service) Forward

func (s *Service) Forward(topicID, msgID, targetAddr, text string) error

Forward commands device to send an outgoing message.

func (*Service) Ping

func (s *Service) Ping(topicID string) error

Ping sends a ping message for testing device connection to service.

type Stats

type Stats struct {
	Published     int32
	Forwarded     int32
	ActiveClients map[string]time.Time
}

Stats is a MQTT service stats.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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