mkoppanen/php-zmq — pull request #91 by alethia7 (2013-06-04 06:04:41+00:00)
Title: Added socket monitor feature

Added zmq_socket_monitor() functionality to provide socket event data. Run tests/035-monitor.phpt to see it in action.

Created ZMQSocket::getSocketMonitor() to return a ZMQSocketMonitor object. ZMQSocketMonitor methods are connect($events = ZMQ_EVENT_ALL), disconnect() and read($flags). ZMQSocketMonitor::read() returns a ZMQEvent object. The ZMQEvent object has standard properties such as ZMQEvent::code, ZMQEvent::desc, ZMQEvent::addr, ZMQEvent::fd, ZMQEvent::err, and ZMQEvent::interval. ZMQEvent::code (numeric) can be matched with ZMQEvent::EVENT_ALL, ZMQEvent::EVENT_CONNECTED, ZMQEvent::EVENT_LISTENING, etc., constants.

Use ZMQPoll to watch ZMQSocket and ZMQSocketMonitor objects for activity.

FYI: Persistent_Id functionality for ZMQSocketMonitor was implemented, but not tested.
In addition, ZMQSocketMonitor may not work with ØMQ 2.2 Stable or PHP < 5.3. Additional #DEFINES could be added support older releases as needed.

035-monitor.phpt can be adjusted to succeed if you approve.