php教程

Event callbacks

If a callback is registered for an event, it will be called when the event becomes active. To associate a callback with event one can pass a callable to either Event::__construct() , or Event::set() , or one of the factory methods like Event::timer() .

An event callback should match the following prototype:

callback ([ mixed $fd = NULL [, int $what [, mixed $arg = NULL ]]] ) : void

fd

The file descriptor, stream resource or socket associated with the event. For signal event fd is equal to the signal number.

what

Bit mask of all events triggered.

arg

User custom data.

Event::timer() expects the callback to match the following prototype:

callback ([ mixed $arg = NULL ] ) : void

arg

User custom data.

Event::signal() expects the callback to match the following prototype:

callback ([ int $signum [, mixed $arg = NULL ]] ) : void

signum

The number of the triggered signal(e.g. SIGTERM ).

arg

User custom data.

User Contributed Notes

xilon dot jul at gmail dot com 27-May-2013 03:23
For event timers, the callback prototype is equivalent to sockets related callback. User arguments are given as the third parameter.

This has been tested under : Event version 1.6.1

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788