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

How can i show the result of filter events in real time instead of showing after loop? #167

Open
jrivas111 opened this issue May 2, 2018 · 7 comments

Comments

@jrivas111
Copy link

jrivas111 commented May 2, 2018

This is my code

<?php

require __DIR__ . '/pami/vendor/autoload.php';
use PAMI\Client\Impl\ClientImpl as PamiClient;
use PAMI\Message\Event\EventMessage;
use PAMI\Listener\IEventListener;
use PAMI\Message\Event\DialEvent;
use PAMI\Message\Event\DialBeginEvent;
use PAMI\Message\Event\DialEndEvent;
use PAMI\Message\Event\HangupEvent;
use PAMI\Message\Event\NewchannelEvent;
$pamiClientOptions = array(
    'host' => 'host',
    'scheme' => 'tcp://',
    'port' => 5038,
    'username' => 'user',
    'secret' => 'pwd',
    'connect_timeout' => 1000,
    'read_timeout' => 1000
);
$pamiClient = new PamiClient($pamiClientOptions);
// Open the connection
$pamiClient->open();
#echo'hello';





$pamiClient->registerEventListener(
    function (EventMessage $event) {
        return 
        $event instanceof NewchannelEvent &&
        print('end call to extention :' . $event->getExtension("Exten") . ' from: ' . $event->getCallerIDNum("CallerIDNum"));
        


        
   }
);


$running = true;
// Main loop
$running = true;
while($running) {
    $pamiClient->process();
    usleep(1000);
}
// Close the connection
$pamiClient->close();

?>
@davicfg
Copy link

davicfg commented Jun 28, 2018

@marcelog, do you know how to do it?

@mstyles
Copy link
Contributor

mstyles commented Jun 29, 2018

I'm not quite sure what you mean by "show the events in real time". Your event loop there is running at a millisecond frequency; that seems pretty real time to me. I'm probably misunderstanding your question, though.

@jrivas111
Copy link
Author

jrivas111 commented Jun 29, 2018 via email

@davicfg
Copy link

davicfg commented Jun 29, 2018

My problem is, I'm sending this data through a WebSocket. I can send some data with actions, by with event i can't, just becouse i cound't get my ws_user to send de message when a event happen.

@mstyles
Copy link
Contributor

mstyles commented Jun 30, 2018

@jrivas111 what do you mean by "after the loop is done"? In the code you posted the loop never ends.

@davicfg are you saying your event listener function is never invoked for events?

@jrivas111
Copy link
Author

jrivas111 commented Jun 30, 2018 via email

@davicfg
Copy link

davicfg commented Jul 1, 2018

Frist off all thank you @jrivas111 to help me.

@jrivas111, it's very strange, becouse i call 5 times the method process from ClientImpl, butg in the end it's all wrong, because sometimes i don't get all the Queuecallerjoin events. I know this 'couse I'm looking to the logs from asterisk and i can see that a caller join a queue, but in the instance of ClientImpl doesn't show me. This is my problem.

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

No branches or pull requests

3 participants