1 Star 0 Fork 2

何吕 / volantmq

forked from JUMEI_ARCH / volantmq 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
server.go 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
hawklin 提交于 2018-05-16 15:06 . 去掉无效的$SYS topic
package systree
import (
"github.com/VolantMQ/volantmq/packet"
"github.com/VolantMQ/volantmq/types"
)
type server struct {
version string
upTime *dynamicValueUpTime
currTime *dynamicValueCurrentTime
capabilities struct {
SupportedVersions []packet.ProtocolVersion
MaxQoS string
MaxConnections uint64
MaximumPacketSize uint32
ServerKeepAlive uint16
ReceiveMaximum uint16
RetainAvailable bool
WildcardSubscriptionAvailable bool
SubscriptionIDAvailable bool
SharedSubscriptionAvailable bool
}
}
func newServer(topicPrefix string, dynRetains, staticRetains *[]types.RetainObject) server {
b := server{
upTime: newDynamicValueUpTime(topicPrefix + "/uptime"),
currTime: newDynamicValueCurrentTime(topicPrefix + "/datetime"),
version: "1.0.0",
}
m, _ := packet.New(packet.ProtocolV311, packet.PUBLISH)
msg, _ := m.(*packet.Publish)
msg.SetQoS(packet.QoS0) // nolint: errcheck
msg.SetTopic(topicPrefix + "/version") // nolint: errcheck
msg.SetPayload([]byte(b.version))
*dynRetains = append(*dynRetains, b.upTime)
*dynRetains = append(*dynRetains, b.currTime)
*staticRetains = append(*staticRetains, msg)
//m, _ = packet.New(packet.ProtocolV311, packet.PUBLISH)
//msg, _ = m.(*packet.Publish)
//msg.SetQoS(packet.QoS0) // nolint: errcheck
//msg.SetTopic(topicPrefix + "/capabilities") // nolint: errcheck
//if data, err := json.Marshal(&b.capabilities); err == nil {
// msg.SetPayload(data)
//} else {
// msg.SetPayload([]byte(err.Error()))
//}
//*staticRetains = append(*staticRetains, msg)
return b
}
Go
1
https://gitee.com/kaifazhe/volantmq.git
git@gitee.com:kaifazhe/volantmq.git
kaifazhe
volantmq
volantmq
v0.0.4

搜索帮助

53164aa7 5694891 3bd8fe86 5694891