Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event filters #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

event filters #107

wants to merge 1 commit into from

Conversation

sctt
Copy link

@sctt sctt commented Sep 21, 2016

when i process events, i need to filter them based on specific event data.
i could use predicates as closures, but that solution is too hard and complex, especially if filters have to be dynamic.
i recommend closures if you really have to filter with some particular criteria, but if you just need to filter evaluating event data, i don't think they are the optimal solution.

that's why i added the capability of specifying an array of filters during event registration.
filters are specified as regular expressions.
here's an example:

$client->registerEventListener(
    function($event) {var_dump($event);},
    array(
        'event' => '/Hangup/',
        'channel' => '/Local\/27.*/',
   )
);

i did some test with a couple of events and filters, and it actually seems to work.

let me know what you think, i will write a unit test only if you like this.

dkgroot pushed a commit to chan-sccp/PAMI that referenced this pull request Apr 23, 2019
Added the capability of specifying an array of filters during event registration.
Filters are specified as regular expressions.

Example:
$client->registerEventListener(
    function($event) {var_dump($event);},
    array(
        'event' => '/Hangup/',
        'channel' => '/Local\/27.*/',
   )
);

Cherry-Picked b442e8c from @sctt (marcelog#107)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant