|
@@ -3,7 +3,6 @@ package main
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
- "fmt"
|
|
|
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
|
"github.com/gogf/gf/os/grpool"
|
|
"github.com/gogf/gf/os/grpool"
|
|
"runtime"
|
|
"runtime"
|
|
@@ -88,7 +87,6 @@ func (d *MqttClient) SubDevMsg(handle Handle) error {
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
- fmt.Printf("err------------------------------%s", err)
|
|
|
|
client.SetMqttSetOnConnectHandler(func(cli mqtt.Client) {
|
|
client.SetMqttSetOnConnectHandler(func(cli mqtt.Client) {
|
|
err := d.subDevMsg(cli, handle)
|
|
err := d.subDevMsg(cli, handle)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -140,18 +138,18 @@ func (d *MqttClient) subDevMsg(cli mqtt.Client, handle Handle) error {
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
- //err = d.subscribeWithFunc(cli, TopicSDKLog, func(ctx context.Context, topic string, payload []byte) error {
|
|
|
|
- // return handle(ctx).Message(topic, payload)
|
|
|
|
- //})
|
|
|
|
- //if err != nil {
|
|
|
|
- // return err
|
|
|
|
- //}
|
|
|
|
- //err = d.subscribeWithFunc(cli, TopicEvent, func(ctx context.Context, topic string, payload []byte) error {
|
|
|
|
- // return handle(ctx).Message(topic, payload)
|
|
|
|
- //})
|
|
|
|
- //if err != nil {
|
|
|
|
- // return err
|
|
|
|
- //}
|
|
|
|
|
|
+ err = d.subscribeWithFunc(cli, TopicSDKLog, func(ctx context.Context, topic string, payload []byte) error {
|
|
|
|
+ return handle(ctx).Message(topic, payload)
|
|
|
|
+ })
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ err = d.subscribeWithFunc(cli, TopicEvent, func(ctx context.Context, topic string, payload []byte) error {
|
|
|
|
+ return handle(ctx).Message(topic, payload)
|
|
|
|
+ })
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|