ZMQDevice
class ZMQDevice (View source)
Class ZMQDevice
Methods
(PECL zmq >= 1.0.4) Construct a new device.
Gets the idle callback timeout value.
Gets the timer callback timeout value.
Runs the device.
Sets the idle callback function.
Sets the idle callback timeout value. The idle callback is invoked periodically when the device is idle.
Sets the timer callback function. The timer callback will be invoked after timeout has passed.
Sets the timer callback timeout value. The timer callback is invoked periodically if it's set.
Details
__construct(ZMQSocket $frontend, ZMQSocket $backend, ZMQSocket $listener = null)
(PECL zmq >= 1.0.4) Construct a new device.
"ØMQ devices can do intermediation of addresses, services, queues, or any other abstraction you care to define above the message and socket layers." -- zguide Call to this method will prepare the device. Usually devices are very long running processes so running this method from interactive script is not recommended. This method throw ZMQDeviceException if the device cannot be started.
int
getIdleTimeout()
Gets the idle callback timeout value.
This method returns the idle callback timeout value. Added in ZMQ extension version 1.1.0.
int
getTimerTimeout()
Gets the timer callback timeout value.
Added in ZMQ extension version 1.1.0.
run()
Runs the device.
Call to this method will block until the device is running. It is not recommended that devices are used from interactive scripts.
ZMQDevice
setIdleCallback(callable $cb_func, int $timeout, mixed $user_data)
Sets the idle callback function.
If idle timeout is defined the idle callback function shall be called if the internal poll loop times out without events. If the callback function returns false or a value that evaluates to false the device is stopped. The callback function signature is callback (mixed $user_data).
ZMQDevice
setIdleTimeout(int $timeout)
Sets the idle callback timeout value. The idle callback is invoked periodically when the device is idle.
On success this method returns the current object.
ZMQDevice
setTimerCallback(callable $cb_func, int $timeout, mixed $user_data)
Sets the timer callback function. The timer callback will be invoked after timeout has passed.
The difference between idle and timer callbacks are that idle callback is invoked only when the device is idle. The callback function signature is callback (mixed $user_data). Added in ZMQ extension version 1.1.0.
ZMQDevice
setTimerTimeout(int $timeout)
Sets the timer callback timeout value. The timer callback is invoked periodically if it's set.
Added in ZMQ extension version 1.1.0.