mqtt

package
v0.0.0-...-cc86588 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QOSAtMostOnce  = byte(0)
	QOSAtLeastOnce = byte(1)
)

Constants for connecting to the MQTT broker

Variables

This section is empty.

Functions

This section is empty.

Types

type Connect

type Connect interface {
	Publish(topic, payload string) error
	Subscribe(topic string, callback MQTT.MessageHandler) error
	Close()
}

Connect is the interface for an MQTT connection

type Connection

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

Connection for MQTT protocol

func GetConnection

func GetConnection(settings *config.Settings) (*Connection, error)

GetConnection fetches or creates an MQTT connection

func (*Connection) Close

func (c *Connection) Close()

Close closes the connection to the MQTT broker

func (*Connection) Publish

func (c *Connection) Publish(topic, payload string) error

Publish sends data to the MQTT broker

func (*Connection) Subscribe

func (c *Connection) Subscribe(topic string, callback MQTT.MessageHandler) error

Subscribe starts a new subscription, providing a message handler for the topic

type MockClient

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

MockClient mocks the MQTT client

func (*MockClient) AddRoute

func (cli *MockClient) AddRoute(topic string, callback MQTT.MessageHandler)

AddRoute mocks routing

func (*MockClient) Connect

func (cli *MockClient) Connect() MQTT.Token

Connect mocks connecting to broker

func (*MockClient) Disconnect

func (cli *MockClient) Disconnect(quiesce uint)

Disconnect mocks client close

func (*MockClient) IsConnected

func (cli *MockClient) IsConnected() bool

IsConnected mocks the connect status

func (*MockClient) IsConnectionOpen

func (cli *MockClient) IsConnectionOpen() bool

IsConnectionOpen mocks the connect status

func (*MockClient) OptionsReader

func (cli *MockClient) OptionsReader() MQTT.ClientOptionsReader

OptionsReader mocks the options reader (badly)

func (*MockClient) Publish

func (cli *MockClient) Publish(topic string, qos byte, retained bool, payload interface{}) MQTT.Token

Publish mocks a publish message

func (*MockClient) Subscribe

func (cli *MockClient) Subscribe(topic string, qos byte, callback MQTT.MessageHandler) MQTT.Token

Subscribe mocks a subscribe message

func (*MockClient) SubscribeMultiple

func (cli *MockClient) SubscribeMultiple(filters map[string]byte, callback MQTT.MessageHandler) MQTT.Token

SubscribeMultiple mocks subscribe messages

func (*MockClient) Unsubscribe

func (cli *MockClient) Unsubscribe(topics ...string) MQTT.Token

Unsubscribe mocks a unsubscribe message

type MockConnect

type MockConnect struct{}

MockConnect is a mock MQTT connection

func (*MockConnect) Close

func (c *MockConnect) Close()

Close mocks a MQTT close method

func (*MockConnect) Publish

func (c *MockConnect) Publish(topic, payload string) error

Publish mocks a MQTT publish method

func (*MockConnect) Subscribe

func (c *MockConnect) Subscribe(topic string, callback MQTT.MessageHandler) error

Subscribe mocks a MQTT subscribe method

type MockMessage

type MockMessage struct {
	Message   []byte
	TopicPath string
}

MockMessage implements an MQTT message

func (*MockMessage) Ack

func (m *MockMessage) Ack()

Ack mocks the message ack

func (*MockMessage) Duplicate

func (m *MockMessage) Duplicate() bool

Duplicate mocks a duplicate message check

func (*MockMessage) MessageID

func (m *MockMessage) MessageID() uint16

MessageID mocks the message ID

func (*MockMessage) Payload

func (m *MockMessage) Payload() []byte

Payload mocks the payload retrieval

func (*MockMessage) Qos

func (m *MockMessage) Qos() byte

Qos mocks the QoS flag

func (*MockMessage) Retained

func (m *MockMessage) Retained() bool

Retained mocks the retained flag

func (*MockMessage) Topic

func (m *MockMessage) Topic() string

Topic mocks the topic

type MockToken

type MockToken struct{}

MockToken implements a Token

func (*MockToken) Error

func (t *MockToken) Error() error

Error mocks a token error check

func (*MockToken) Wait

func (t *MockToken) Wait() bool

Wait mocks the token wait

func (*MockToken) WaitTimeout

func (t *MockToken) WaitTimeout(time.Duration) bool

WaitTimeout mocks the token wait timeout

Jump to

Keyboard shortcuts

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