Hi. I'm modifying the faye-redis engine for business purposes and I'm finding the need to tell a client that publishes a message whether the message was delivered to any subscribers. One could extrapolate this to, on publish, give the client information relevant to the outcome of the publish.
My understanding of the current faye-redis engine is that it basically fires the engine.publish and turns around and immediately sends a publish acknowledgement to the client (with a success or error). There is no asynchronous waiting on the publish.
The engines/proxy.publish function appears to accept a return from engine.publish, however, if I tweak the engine code to return a promise and have protocol.server._handle add a .then and send it's response in the .then, the published message is apparently not marked as "resolved" and the message is republished every approximately 45 seconds.
If I instead tweak the protocol/server._handle method to pass a callback, tweak engines.proxy to pass that callback to engine.publish, and in engine.publish call the callback, things continue to work properly, and no duplicate messages are sent after the timeout. I can then insert whatever data I want by invoking the callback with whatever I want, such as a boolean about whether the message was delivered.
I hesitate to make tweaks to the faye library code and am curious if others have solved this issue. I am also considering, instead of tweaking proxy.js and server.js, sending an independent asynchronous "/meta/status" message to the client, and using, say, an incoming hook on the client to pull these types of meta messages off and do something with them.