Event socket bug fix and more docs (#6823)

* Add documentation to methods. Use is_resource for added type detection

* Allow connect to specify timeout in microseconds with default 30,000

* Update calling mechanism for event sockets

* Update project for new singleton event sockets

* remove unused variable

* catch errors on closing the socket
This commit is contained in:
frytimo
2023-12-02 17:16:18 -07:00
committed by GitHub
parent 44567f7a05
commit 3a4c2f72e2
74 changed files with 1620 additions and 1533 deletions
@@ -60,7 +60,7 @@ if (!class_exists('registrations')) {
$id = 0;
//create the event socket connection
$fp = event_socket_create();
$esl = event_socket::create();
//get the default settings
$sql = "select sip_profile_name from v_sip_profiles ";
@@ -77,7 +77,7 @@ if (!class_exists('registrations')) {
//get sofia status profile information including registrations
$cmd = "api sofia xmlstatus profile '".$field['sip_profile_name']."' reg";
$xml_response = trim(event_socket_request($fp, $cmd));
$xml_response = trim(event_socket::command($cmd));
//show an error message
if ($xml_response == "Invalid Profile!") {
@@ -269,10 +269,10 @@ if (!class_exists('registrations')) {
unset($sql);
//create the event socket connection
$fp = event_socket_create();
$esl = event_socket::create();
//loop through registrations
if ($fp) {
if ($esl->is_connected()) {
//check if registrations exist
if (is_array($registrations)) {
foreach ($registrations as $registration) {
@@ -332,9 +332,9 @@ if (!class_exists('registrations')) {
}
//send the api command
if (!empty($command) && $fp) {
$response_api[$registration['user']]['command'] = event_socket_request($fp, "api ".$command);
$response_api[$registration['user']]['log'] = event_socket_request($fp, "api log notice ".$command);
if (!empty($command) && $esl->is_connected()) {
$response_api[$registration['user']]['command'] = event_socket::api($command);
$response_api[$registration['user']]['log'] = event_socket::api("log notice $command");
}
}