mqttutil

package
v0.2024.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, options *mqtt.ClientOptions) (mqtt.Client, error)

func SendJSON

func SendJSON(ctx context.Context, client mqtt.Client, topic string, payload any) error

SendJSON converts payload to JSON and sends on topic to client. payload will be converted to JSON using the following rules:

  1. if payload is a []byte, string, or bytes.Buffer, it will be sent as-is
  2. if payload is a proto.Message, it will be converted using protojson.Marshal
  3. otherwise, it will be converted using json.Marshal

func WaitToken

func WaitToken(ctx context.Context, token mqtt.Token) (completed bool, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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