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 20:16:18 -04:00
committed by GitHub
parent 44567f7a05
commit 3a4c2f72e2
74 changed files with 1620 additions and 1533 deletions

View File

@@ -57,7 +57,7 @@ if (count($_GET) > 0) {
$direction = trim($_GET["direction"] ?? '');
//setup the event socket connection
$fp = event_socket_create();
$esl = event_socket::create();
//allow specific commands
if (!empty($switch_cmd)) {
@@ -99,7 +99,7 @@ if (count($_GET) > 0) {
}
//run the command
$switch_result = event_socket_request($fp, 'api '.$api_cmd);
$switch_result = event_socket::api($api_cmd);
/*
//record stop

View File

@@ -97,15 +97,15 @@
//update the user_status
if (is_uuid($call_center_agent_uuid)) {
$fp = event_socket_create();
$esl = event_socket::create();
$switch_cmd .= "callcenter_config agent set status ".$call_center_agent_uuid." '".$user_status."'";
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
$switch_result = event_socket::api($switch_cmd);
}
//update the user state
if (is_uuid($call_center_agent_uuid)) {
$cmd = "api callcenter_config agent set state ".$call_center_agent_uuid." Waiting";
$response = event_socket_request($fp, $cmd);
$response = event_socket::api($cmd);
}
//update do not disturb

View File

@@ -86,10 +86,12 @@ if (!class_exists('basic_operator_panel')) {
}
//send the command
$fp = event_socket_create();
if ($fp) {
$switch_result = event_socket_request($fp, 'api show channels as json');
$switch_result = event_socket::api('show channels as json');
if ($switch_result !== false) {
$fp = true;
$json_array = json_decode($switch_result, true);
} else {
$fp = false;
}
//build the response
@@ -205,8 +207,10 @@ if (!class_exists('basic_operator_panel')) {
if ($fp) {
if (is_uuid($field['uuid'])) {
$switch_cmd = 'uuid_dump '.$field['uuid'].' json';
$dump_result = event_socket_request($fp, 'api '.$switch_cmd);
$dump_array = json_decode($dump_result, true);
$dump_result = event_socket::api($switch_cmd);
if ($dump_result !== false) {
$dump_array = json_decode($dump_result, true);
}
if (is_array($dump_array)) {
foreach ($dump_array as $dump_var_name => $dump_var_value) {
$array[$x][$dump_var_name] = $dump_var_value;

View File

@@ -64,9 +64,8 @@ if (!empty($groups)) {
}
//get the valet info
$fp = event_socket_create();
if ($fp) {
$valet_info = event_socket_request($fp, 'api valet_info park@'.$_SESSION['domain_name']);
$valet_info = event_socket::api('valet_info park@'.$_SESSION['domain_name']);
if ($valet_info !== false) {
//get an array of the valet call uuid and park numbers
if (isset($valet_info)) {
@@ -78,10 +77,10 @@ if ($fp) {
//unset($_SESSION['valet']);
foreach($valet_matches as $row) {
if (!isset($_SESSION['valet']['uuid']['caller_id_name'])) {
$_SESSION['valet'][$row[1]]['caller_id_name'] = event_socket_request($fp, 'api uuid_getvar '.$row[1].' caller_id_name');
$_SESSION['valet'][$row[1]]['caller_id_name'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_name');
}
if (!isset($_SESSION['valet']['uuid']['caller_id_number'])) {
$_SESSION['valet'][$row[1]]['caller_id_number'] = event_socket_request($fp, 'api uuid_getvar '.$row[1].' caller_id_number');
$_SESSION['valet'][$row[1]]['caller_id_number'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_number');
}
}