broker

package
v0.0.0-...-064367d Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2015 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

broker is an package about define MQTT connecion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBrokerNames

func GetBrokerNames(brokers []*Broker) []string

func MQTTConnect

func MQTTConnect(gwName string, b *Broker) (*MQTT.Client, error)

MQTTConnect returns MQTTClient with options.

func NewTLSConfig

func NewTLSConfig(caCertFilePath string) (*tls.Config, error)

NewTLSConfig returns TLS config from CA Cert file path.

Types

type Broker

type Broker struct {
	GatewayName   string
	Name          string `validate:"max=256,regexp=[^/]+,validtopic"`
	Priority      int    `validate:"min=1,max=3"`
	Host          string `validate:"max=256"`
	Port          int    `validate:"min=1,max=65535"`
	Username      string `validate:"max=256"`
	Password      string `validate:"max=256"`
	RetryInterval int    `validate:"min=0"`
	TopicPrefix   string `validate:"max=256"`
	WillMessage   []byte `validate:"max=256"`
	Tls           bool
	CaCert        string `validate:"max=256"`
	TLSConfig     *tls.Config
	Subscribed    Subscribed // list of subscribed topics

	GwChan chan message.Message

	MQTTClient *MQTT.Client
	// contains filtered or unexported fields
}

func (*Broker) AddSubscribed

func (b *Broker) AddSubscribed(deviceName string, qos byte) error

func (*Broker) Close

func (b *Broker) Close() error

func (*Broker) DeleteSubscribed

func (b *Broker) DeleteSubscribed(deviceName string, qos byte) error

func (*Broker) FourceClose

func (b *Broker) FourceClose() error

func (*Broker) GenerateTopic

func (b *Broker) GenerateTopic(msg *message.Message) (message.TopicString, error)

GenerateTopic generates topic from topicprefix, gwname and message.

func (*Broker) IsConnected

func (b *Broker) IsConnected() bool

func (*Broker) MQTTClientSetup

func (b *Broker) MQTTClientSetup(gwName string) error

MQTTClientSetup setup MQTTOptions and connect ot broker.

func (*Broker) Publish

func (b *Broker) Publish(msg *message.Message) error

func (*Broker) String

func (broker *Broker) String() string

func (*Broker) SubscribeOnConnect

func (b *Broker) SubscribeOnConnect(client *MQTT.Client)

type Brokers

type Brokers []*Broker

func NewBrokers

func NewBrokers(conf inidef.Config, gwChan chan message.Message) (Brokers, error)

NewBrokers returns []*Broker from inidef.Config. If validation failes, retrun error.

func (Brokers) Len

func (bs Brokers) Len() int

func (Brokers) Less

func (bs Brokers) Less(i, j int) bool

func (Brokers) Swap

func (bs Brokers) Swap(i, j int)

type Subscribed

type Subscribed struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSubscribed

func NewSubscribed() Subscribed

func (Subscribed) Add

func (s Subscribed) Add(topic string, qos byte) error

func (Subscribed) Delete

func (s Subscribed) Delete(topic string) error

func (Subscribed) Length

func (s Subscribed) Length() int

func (Subscribed) List

func (s Subscribed) List() map[string]byte

Jump to

Keyboard shortcuts

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