add_event_handler question

  • Eric Wieling

    Eric Wieling - 2010-09-17

    I'm using php from the command line for testing.

    I'm trying to use add_event_handler.  I want to each event to fire off my event handler, then wait for another event.

    Here is the code I'm using.  I tried it with and without the while and sleep as well.  Does anyone have any pointers on making this work?  My background is not in OO style programming.


    $manager = new AGI_AsteriskManager();
    $result = $manager->connect();
    if($result === TRUE) {
        echo "Connection established.\n";
        $manager->add_event_handler("*", "dump_event");
        while (1 == 1) {
    } else {
        echo "Connection failed.\n";

    function dump_event($ecode,$data,$server,$port) {
    echo "received event '$ecode' from $server:$port\n";

  • Matthew Asham

    Matthew Asham - 2010-09-17

    You need to setup an eventmask to indicate what events your manager application should receive, eg:


    Check phpagi-asmanager.php for more information.

  • Jack

    Jack - 2012-04-15

    The trick is to loop but not sleep since while sleeping you ain't receiving anything.
    Just do the following


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks