JustinTulloss/zeromq.node — pull request #254 by f34rdotcom (2013-11-22 03:02:04+00:00)
Title: Monitor

Based upon the fork by dr-fozzy but from current master and with lots of added work / testing.

Bug fixes.
1. monitor socket address not changing so only one socket would ever work.
2. monitoring does not use real sockets so no FD is available and socket poll will not work and it never really monitored any events.

Improvements.
1. Making monitoring "optional" not forced for every socket.
2. Added the second arg to the event the fd, error, etc.
3. Added an unmonitor method to release the socket and the idle handler

Not a perfect solution in dealing with cleanup when the Socket::Close() happens the context could go away so it can't catch any events after that. A refactor of ::Close to cleanup the context differently when monitoring is on or use a separate context handle for monitoring should be looked at. To work around the Closed socket I did a few things to get the Socket directly bypassing GET_SOCKET.

It works and I am using this to track connected clients in my pub/sub pattern going idle when the count reaches 0 and active when > 0