Add PubMessge
This commit is contained in:
parent
f135802a46
commit
0c64ac1523
38
mqtt.go
38
mqtt.go
@ -19,22 +19,22 @@ type Message interface {
|
||||
Ack()
|
||||
}
|
||||
|
||||
type message struct {
|
||||
duplicate bool
|
||||
qos byte
|
||||
retained bool
|
||||
topic string
|
||||
messageID uint16
|
||||
payload []byte
|
||||
ack func()
|
||||
type PubMessage interface {
|
||||
Topic() string
|
||||
Payload() []byte
|
||||
Qos() byte
|
||||
Retained() bool
|
||||
}
|
||||
|
||||
func (m *message) Duplicate() bool {
|
||||
return m.duplicate
|
||||
type message struct {
|
||||
qos int
|
||||
retained bool
|
||||
topic string
|
||||
payload []byte
|
||||
}
|
||||
|
||||
func (m *message) Qos() byte {
|
||||
return m.qos
|
||||
return byte(m.qos)
|
||||
}
|
||||
|
||||
func (m *message) Retained() bool {
|
||||
@ -45,19 +45,17 @@ 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}
|
||||
func NewPubMessage(topic string, payload []byte, qos int, retained bool) *message {
|
||||
return &message{
|
||||
topic: topic,
|
||||
payload: payload,
|
||||
qos: qos,
|
||||
retained: retained,
|
||||
}
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user