Add dummy message object

This commit is contained in:
Nicolas Duhamel 2022-12-25 21:53:58 +01:00
parent e2ef561b61
commit f135802a46

41
mqtt.go
View File

@ -19,6 +19,47 @@ type Message interface {
Ack() Ack()
} }
type message struct {
duplicate bool
qos byte
retained bool
topic string
messageID uint16
payload []byte
ack func()
}
func (m *message) Duplicate() bool {
return m.duplicate
}
func (m *message) Qos() byte {
return m.qos
}
func (m *message) Retained() bool {
return m.retained
}
func (m *message) Topic() string {
return m.topic
}
func (m *message) MessageID() uint16 {
return m.messageID
}
func (m *message) Payload() []byte {
return m.payload
}
func (m *message) Ack() {
}
func NewSimpleMessage(topic string, payload []byte, retained bool) *message {
return &message{topic: topic, payload: payload, retained: retained}
}
type Config struct { type Config struct {
Host string Host string
Port string Port string