mqtt加入认证,优化视频播放与浏览器
This commit is contained in:
@@ -40,6 +40,7 @@ func buildMqtt(c config.MqttConfig, r *leaf.Engine, subTopics ...string) autopah
|
||||
mqttConfig := autopaho.ClientConfig{
|
||||
ServerUrls: []*url.URL{u},
|
||||
KeepAlive: 20,
|
||||
ConnectPassword: []byte(c.Password),
|
||||
CleanStartOnInitialConnection: false,
|
||||
SessionExpiryInterval: 60,
|
||||
OnConnectionUp: func(cm *autopaho.ConnectionManager, _ *paho.Connack) {
|
||||
@@ -56,7 +57,7 @@ func buildMqtt(c config.MqttConfig, r *leaf.Engine, subTopics ...string) autopah
|
||||
zap.S().Infof("MQTT 连接异常: %s\n", err)
|
||||
},
|
||||
ClientConfig: paho.ClientConfig{
|
||||
ClientID: fmt.Sprintf("game-driver-%s-%v", config.C.Location, config.C.Point),
|
||||
ClientID: c.ClientID,
|
||||
OnPublishReceived: []func(paho.PublishReceived) (bool, error){
|
||||
func(pr paho.PublishReceived) (bool, error) {
|
||||
r.Route(pr.Packet.Packet())
|
||||
@@ -109,8 +110,8 @@ func Run() {
|
||||
|
||||
router := leaf.Default(ctx)
|
||||
|
||||
log, _ := zap.NewStdLogAt(zap.L(), zap.DebugLevel)
|
||||
router.SetDebugLogger(log)
|
||||
logAt, _ := zap.NewStdLogAt(zap.L(), zap.DebugLevel)
|
||||
router.SetDebugLogger(logAt)
|
||||
|
||||
router.DefaultHandler(func(c *leaf.Context) {
|
||||
zap.S().Infof("未处理消息,topic: %s\n payload: %s\n", c.Topic, c.Payload)
|
||||
|
||||
Reference in New Issue
Block a user