mqtthandle.go 602 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "lc/common/protocol"
  4. )
  5. type MqttOnline struct {
  6. }
  7. func (o *MqttOnline) GetOnlineMsg() (string, string) {
  8. //发布上线消息
  9. var obj protocol.Pack_IDObject
  10. str, err := obj.EnCode(appConfig.GID, GetNextUint64(), 0)
  11. if err != nil {
  12. return "", ""
  13. }
  14. return GetTopic(protocol.DT_GATEWAY, appConfig.GID, protocol.TP_GW_ONLINE), str
  15. }
  16. func (o *MqttOnline) GetWillMsg() (string, string) {
  17. payload, _ := (&protocol.Pack_IDObject{}).EnCode(appConfig.GID, GetNextUint64(), 0) //遗嘱消息
  18. return GetTopic(protocol.DT_GATEWAY, appConfig.GID, protocol.TP_GW_WILL), payload
  19. }