Documentation
¶
Index ¶
- Variables
- func TopicControl(topic string) string
- func TopicData(topic string) string
- type Callback
- type MQTT
- type MQTTPrinter
- type Message
- type Messanger
- type MockClient
- func (m *MockClient) AddRoute(topic string, callback gomqtt.MessageHandler)
- func (m *MockClient) Connect() gomqtt.Token
- func (m *MockClient) Disconnect(quiecense uint)
- func (m *MockClient) IsConnected() bool
- func (m *MockClient) IsConnectionOpen() bool
- func (m *MockClient) MessageHandler(c gomqtt.Client, mm gomqtt.Message)
- func (m *MockClient) OptionsReader() gomqtt.ClientOptionsReader
- func (m *MockClient) Publish(topic string, qos byte, retained bool, payload interface{}) gomqtt.Token
- func (m *MockClient) Subscribe(topic string, qos byte, mh gomqtt.MessageHandler) gomqtt.Token
- func (m *MockClient) SubscribeMultiple(filters map[string]byte, callback gomqtt.MessageHandler) gomqtt.Token
- func (m *MockClient) Unsubscribe(topics ...string) gomqtt.Token
- type MockMessage
- type MockToken
- type Msg
- type MsgHandle
- type MsgSaver
- type Publisher
- type Sub
- type Subscriber
- type TopicList
Constants ¶
This section is empty.
Variables ¶
var ( Topics TopicList TopicBase string )
Functions ¶
func TopicControl ¶
Types ¶
type MQTT ¶
type MQTT struct { ID string `json:"id"` Broker string `json:"broker"` Debug bool `json:"debug"` Subscribers map[string][]MsgHandle `json:"subscribers"` Publishers map[string]int `json:"publishers"` gomqtt.Client `json:"-"` }
MQTT is a wrapper around the Paho MQTT Go package Wraps the Broker, ID and Debug variables.
func SetMQTTClient ¶ added in v0.0.7
func (*MQTT) Connect ¶
Connect to the MQTT broker after setting some MQTT options then connecting to the MQTT broker
func (*MQTT) IsConnected ¶
IsConnected will tell you if the MQTT client is connected to the specified broker
func (MQTT) PublishMsg ¶ added in v0.0.7
Publish messanger will publish a messanger
type MQTTPrinter ¶
type MQTTPrinter struct { }
MQTTPrinter defines the struct that simply prints what ever message is sent to a given topic
func (*MQTTPrinter) Callback ¶
func (mp *MQTTPrinter) Callback(msg *Msg)
Callback will print out all messages sent to the given topic from the MQTTPrinter
type Messanger ¶
type Messanger interface { Publisher() Subscriber() }
Messanger represents a type that can publish and subscribe to messages
type MockClient ¶
func GetMockClient ¶
func GetMockClient() *MockClient
func (*MockClient) AddRoute ¶
func (m *MockClient) AddRoute(topic string, callback gomqtt.MessageHandler)
func (*MockClient) Connect ¶
func (m *MockClient) Connect() gomqtt.Token
func (*MockClient) Disconnect ¶
func (m *MockClient) Disconnect(quiecense uint)
func (*MockClient) IsConnected ¶
func (m *MockClient) IsConnected() bool
func (*MockClient) IsConnectionOpen ¶
func (m *MockClient) IsConnectionOpen() bool
func (*MockClient) MessageHandler ¶
func (m *MockClient) MessageHandler(c gomqtt.Client, mm gomqtt.Message)
func (*MockClient) OptionsReader ¶
func (m *MockClient) OptionsReader() gomqtt.ClientOptionsReader
func (*MockClient) Subscribe ¶
func (m *MockClient) Subscribe(topic string, qos byte, mh gomqtt.MessageHandler) gomqtt.Token
func (*MockClient) SubscribeMultiple ¶
func (m *MockClient) SubscribeMultiple(filters map[string]byte, callback gomqtt.MessageHandler) gomqtt.Token
func (*MockClient) Unsubscribe ¶
func (m *MockClient) Unsubscribe(topics ...string) gomqtt.Token
type MockMessage ¶
type MockMessage struct {
// contains filtered or unexported fields
}
func (MockMessage) Ack ¶
func (m MockMessage) Ack()
func (MockMessage) Duplicate ¶
func (m MockMessage) Duplicate() bool
func (MockMessage) MessageID ¶
func (m MockMessage) MessageID() uint16
func (MockMessage) Payload ¶
func (m MockMessage) Payload() []byte
func (MockMessage) Qos ¶
func (m MockMessage) Qos() byte
func (MockMessage) Retained ¶
func (m MockMessage) Retained() bool
func (MockMessage) Topic ¶
func (m MockMessage) Topic() string
type Msg ¶ added in v0.0.7
type Msg struct { ID int64 `json:"id"` Topic string `json:"topic"` Path []string `json:"path"` Args []string `json:"args"` Data []byte `json:"msg"` Source string `json:"source"` Timestamp time.Duration `json:"timestamp"` }
Msg holds a value and some type of meta data to be pass around in the system.
type MsgHandle ¶
type MsgHandle func(msg *Msg)
Subscriber is an interface that defines a struct needs to have the Callback(topic string, data []byte) function defined.
type MsgSaver ¶ added in v0.0.7
func GetMsgSaver ¶ added in v0.0.7
func GetMsgSaver() *MsgSaver
func (*MsgSaver) ServeHTTP ¶ added in v0.0.7
func (ms *MsgSaver) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP will respond to the writer with 'Pong'
func (*MsgSaver) StartSaving ¶ added in v0.0.7
func (ms *MsgSaver) StartSaving()
func (*MsgSaver) StopSaving ¶ added in v0.0.7
func (ms *MsgSaver) StopSaving()
type Publisher ¶
type Publisher interface {
Publish(msg *Msg)
}
Publisher interface allows objects to publish message to a particular topic as defined in the message.Msg
type Subscriber ¶
type Subscriber interface {
Callback(msg *Msg)
}
Subscriber interface defines a type that can subscribe to published messages