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()
|
Ack()
|
||||||
}
|
}
|
||||||
|
|
||||||
type message struct {
|
type PubMessage interface {
|
||||||
duplicate bool
|
Topic() string
|
||||||
qos byte
|
Payload() []byte
|
||||||
retained bool
|
Qos() byte
|
||||||
topic string
|
Retained() bool
|
||||||
messageID uint16
|
|
||||||
payload []byte
|
|
||||||
ack func()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *message) Duplicate() bool {
|
type message struct {
|
||||||
return m.duplicate
|
qos int
|
||||||
|
retained bool
|
||||||
|
topic string
|
||||||
|
payload []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *message) Qos() byte {
|
func (m *message) Qos() byte {
|
||||||
return m.qos
|
return byte(m.qos)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *message) Retained() bool {
|
func (m *message) Retained() bool {
|
||||||
@ -45,19 +45,17 @@ func (m *message) Topic() string {
|
|||||||
return m.topic
|
return m.topic
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *message) MessageID() uint16 {
|
|
||||||
return m.messageID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *message) Payload() []byte {
|
func (m *message) Payload() []byte {
|
||||||
return m.payload
|
return m.payload
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *message) Ack() {
|
func NewPubMessage(topic string, payload []byte, qos int, retained bool) *message {
|
||||||
}
|
return &message{
|
||||||
|
topic: topic,
|
||||||
func NewSimpleMessage(topic string, payload []byte, retained bool) *message {
|
payload: payload,
|
||||||
return &message{topic: topic, payload: payload, retained: retained}
|
qos: qos,
|
||||||
|
retained: retained,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user