mcollina/mosca — pull request #168 by mocheng (2014-07-06 04:45:05+00:00)
Title: add opts.forwardFilter

This is just a proposal.

This change comes from real product requirement. Our application require different message packets have different expiration TTL. However, there is one `ttl.packets` option for all packets in Mosca currently.

For the time being, our application has one tweak on Mosca as this PR suggests. For each packet, when it is actually `forward`-ed, a callback function in `opts` is invoked. This gives a chance to application layer to decide whether this packet is expired or not. Our packet payload has `ts` and `ttl` field, so that application layer can return `true` or `false` accordingly. If `true` is returned, the packet is not forwared. If `false` is returned, the packet is forwarded as shown green light.

I believe that other application should have same requirements.

Is there any better approach to fulfil the need?