Skip to content

Commit

Permalink
v1.5.1: update
Browse files Browse the repository at this point in the history
  • Loading branch information
mizuki1412 committed Aug 23, 2022
1 parent 4c7c699 commit d5c23df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions service/mqttkit/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func New() *MQTT.Client {
panic(exception.New("请填写broker"))
}
opts.AddBroker(configkit.GetStringD(configkey.MQTTBroker))
opts.SetKeepAlive(time.Duration(1) * time.Minute)
opts.SetKeepAlive(time.Duration(10) * time.Second)
opts.SetAutoReconnect(true)
opts.SetConnectRetry(true)
opts.SetConnectRetryInterval(time.Duration(5) * time.Second)
Expand Down Expand Up @@ -83,10 +83,14 @@ func Publish(topic string, qos byte, retained bool, payload any) error {
New()
}
token := client.Publish(topic, qos, retained, payload)
token.Wait()
token.WaitTimeout(time.Duration(1) * time.Minute)
if token.Error() != nil {
logkit.Error(token.Error().Error())
return token.Error()
}
return nil
}

func GetClient() MQTT.Client {
return client
}
6 changes: 6 additions & 0 deletions service/storagekit/localStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func SaveBytesInHome(data []byte, path string) {
_ = filekit.WriteFile(path, data)
}

func SaveBytesAppendInHome(data []byte, path string) {
path = GetFullPath(path)
_ = filekit.CheckFilePath(path)
_ = filekit.WriteFileAppend(path, data)
}

func GetInHome(path string) []byte {
path = GetFullPath(path)
//file,err := os.OpenFile(path, os.O_RDONLY, 644)
Expand Down

0 comments on commit d5c23df

Please sign in to comment.