Understand the Event Hooks system
mainComqtt uses a universal event hooks system that allows developers to intercept and modify the server and client lifecycle. Hooks are used for implementing authentication, persistent storage, and debugging tools.
Key characteristics:
- Stackable: You can add multiple hooks to a server. They are executed in the order they were added.
- Modifiable: Some hooks can modify values; these modified values are passed to subsequent hooks in the stack before being returned to the runtime code.
Available Hook Types:
- Access Control:
mqtt/hooks/auth.AllowHook(allows all) ormqtt/hooks/auth.Auth(rule-based). - Persistence:
mqtt/hooks/storage/badger(BadgerDB),mqtt/hooks/storage/redis(Redis), ormqtt/hooks/storage/bolt(BoltDB - deprecated). - Debugging:
mqtt/hooks/debug(visualizes packet flow).