I'm building application in Laravel 8
. In application I need to receive event from Asterisk
. To do that I downloaded Pami package.
In app\Listeners folder I created file AmiTestListener.php
for listener (code I copied from Marcelog Pami website):
<?php
use PAMI\Client\Impl\ClientImpl as PamiClient;
use PAMI\Message\Event\EventMessage;
use PAMI\Listener\IEventListener;
$pamiClientOptions = array(
'host' => '85.34.56.189',
'scheme' => 'tcp://',
'port' => 5045,
'username' => 'admin',
'secret' => 'mysecret',
'connect_timeout' => 10000,
'read_timeout' => 10000
);
$pamiClient = new PamiClient($pamiClientOptions);
// Open the connection
$pamiClient->open();
$pamiClient->registerEventListener(function (EventMessage $event) {
var_dump($event);
});
$running = true;
// Main loop
while($running) {
$pamiClient->process();
usleep(1000);
}
// Close the connection
$pamiClient->close();
Connection with FreePbx
on given address works. I can connect. But I can't receive any event.
Above listener I registered in app\Providers\EventServiceProvider.php
:
use App\Listeners\AmiTestNotification;
use App\Listeners\AmiTestListener;
use App\Events\AmiTestProcessed;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
AmiTestListener::class
]
];
When I call using my mobile phone to FreePbox
, connection with Jitsi application is established and I can talk with my mobile phone and Jitsi. But I can't receive any event from FreePbx.