upate plugin logic

This commit is contained in:
joy.zhou
2019-08-16 17:59:15 +08:00
parent e8ceea87b4
commit 93c02b0ea9
41 changed files with 429 additions and 890 deletions
+9 -9
View File
@@ -15,7 +15,7 @@ import (
"github.com/fhmq/hmq/broker/lib/sessions"
"github.com/fhmq/hmq/broker/lib/topics"
"github.com/fhmq/hmq/plugins"
"github.com/fhmq/hmq/plugins/bridge"
"github.com/eclipse/paho.mqtt.golang/packets"
"go.uber.org/zap"
@@ -217,10 +217,10 @@ func (c *client) processClientPublish(packet *packets.PublishPacket) {
}
//publish kafka
c.broker.Publish(&plugins.Elements{
c.broker.Publish(&bridge.Elements{
ClientID: c.info.clientID,
Username: c.info.username,
Action: plugins.Publish,
Action: bridge.Publish,
Timestamp: time.Now().Unix(),
Payload: string(packet.Payload),
Topic: topic,
@@ -278,10 +278,10 @@ func (c *client) processClientSubscribe(packet *packets.SubscribePacket) {
continue
}
b.Publish(&plugins.Elements{
b.Publish(&bridge.Elements{
ClientID: c.info.clientID,
Username: c.info.username,
Action: plugins.Subscribe,
Action: bridge.Subscribe,
Timestamp: time.Now().Unix(),
Topic: topic,
})
@@ -361,10 +361,10 @@ func (c *client) processClientUnSubscribe(packet *packets.UnsubscribePacket) {
{
//publish kafka
b.Publish(&plugins.Elements{
b.Publish(&bridge.Elements{
ClientID: c.info.clientID,
Username: c.info.username,
Action: plugins.Unsubscribe,
Action: bridge.Unsubscribe,
Timestamp: time.Now().Unix(),
Topic: topic,
})
@@ -412,10 +412,10 @@ func (c *client) Close() {
c.status = Disconnected
b := c.broker
b.Publish(&plugins.Elements{
b.Publish(&bridge.Elements{
ClientID: c.info.clientID,
Username: c.info.username,
Action: plugins.Disconnect,
Action: bridge.Disconnect,
Timestamp: time.Now().Unix(),
})