mochi-mqtt / server

The fully compliant, embeddable high-performance Go MQTT v5 server for IoT, smarthome, and pubsub
MIT License
1.3k stars 223 forks source link

怎么在Hook里面访问Publish? #332

Closed OpenJarvisAI closed 1 year ago

OpenJarvisAI commented 1 year ago

在自定义的hook里面:

func (h *CustomHook) OnConnectAuthenticate(cl *mqtt.Client, pk packets.Packet) bool {
    cl.
    res := MyAuthorizeHandler(cl, pk)
    return res
}

我想要利用inline 的client,发布消息,怎么获取的到server啊?

werbenhu commented 1 year ago

参考 #330

werbenhu commented 1 year ago

@OpenJarvisAI 已经更新的example中的示例怎么使用,参考:https://github.com/mochi-mqtt/server/blob/main/examples/hooks/main.go