How can i show the result of filter events in real time instead of showing after loop?
jrivas111 opened this issue · comments
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();
?>
@marcelog, do you know how to do it?
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.
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.
@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?
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.