-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a preUnsubscribe handler, analog to authorizeSubscribe
Invoked then a client unsubscribes from topics. Just like authorizeSubscribe, this function allows modifying the topics because executing the unsubscribe. This is needed in cases where topics are modified in authorizeSubscribe. For example: ```js aedes.authorizeSubscribe = (client, subscription, callback) => { // overwrite subscription: force client to its namespace subscription.topic = `/${client.id}/${subscription.topic}`; callback(null, subscription); } aedes.preUnsubscribe = (client, packet, callback) => { // overwrite unsubscriptions: force client to its namespace for (let i in packet.unsubscriptions) { packet.unsubscriptions[i] = `/${client.id}/${packet.unsubscriptions[i]}`; } callback(client, packet) } ``` Includes fix-ups: - Update docs/Aedes.md Co-authored-by: Daniel Lando <[email protected]> - added defaultPreUnsubscribe - made preUnsubscribe async like authorizeSubscribe
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters