express-longpoll
express-longpoll copied to clipboard
Added new subscriber callback
Hey there, I hope you find this useful. We have an application that required the server to return some status information at the end of a long-poll period, say 60s. I guess normally the client would timeout, but we wanted the server to. So we created a callback for when a new client request is made. It might be a bit quick, let me know if you want it tidied up a bit or added to tests. Cheers.
Great idea! Tests would be great as I can't push the changes without the tests. Also since we are adding callbacks I think that there should be callbacks specific to each endpoint so this could be the "GlobalCallback" that runs for all endpoints, and then another that is added when you create an endpoint, for example
longpoll.create("/hello", subscribeCallback1);
longpoll.create("/world", subscribeCallback2);
longpoll.setGlobalCallback(globalSubscribeCallback); // or through initial config
I'll take care of the endpoint specific callbacks.
Thanks for making a pull request!