simontelephonics / smsconnector

SMS Connector module for FreePBX 16 and 17
https://simon.tel/open-source/
GNU General Public License v3.0
36 stars 15 forks source link

Optimize daemon smsconnector #34

Closed vsc55 closed 6 months ago

vsc55 commented 6 months ago

Hi @billsimon,

About this: https://github.com/simontelephonics/smsconnector/blob/c6ef6a5acb9c44225eb96af338de6dcff289de56/sipsmsdaemon.php#L37-L39

Did you try something like this?

...
if ($astman->connected())
{
    $smsconnector = \FreePBX::Create()->Smsconnector();
    $astman->Events('on');
    $astman->add_event_handler('UserEvent', function($event, $data, $server, $port) use (&$smsconnector) { userEventHandler($data, $smsconnector); });
}
...
function userEventHandler($data, $smsconnector)
{
...
}

What do you think?

billsimon commented 6 months ago

I found a better way to handle messages that does not require a long running process so this code is going to go away entirely in the next release (soon). Thank you for the help!