Cleaned up messages

Improved message readability. Atom removed extraneous white spaces and lines
This commit is contained in:
steve-lad 2021-01-28 10:25:02 +01:00
parent 80fbf7b1b4
commit 48041fc62c
5 changed files with 33 additions and 36 deletions

View file

@ -12,7 +12,7 @@ namespace FreePBX\modules\Sccp_manager\aminterface;
class AMIException extends \Exception
{
}
abstract class Message

View file

@ -72,7 +72,6 @@ abstract class Response extends IncomingMessage
$this->setKey('ActionId', $actionId);
}
public function getVariable($_rawContent, $_fields = '')
{
$lines = explode(Message::EOL, $_rawContent);
@ -119,7 +118,6 @@ class Login_Response extends Response
class Command_Response extends Response
{
private $_temptable;
public function __construct($rawContent)
{
// print_r('<br>---- r --<br>');
@ -127,7 +125,6 @@ class Command_Response extends Response
// print_r('<br>---- re --<br>');
$this->_temptable = array();
parent::__construct($rawContent);
$lines = explode(Message::EOL, $rawContent);
foreach ($lines as $line) {
$content = explode(':', $line);
@ -148,7 +145,7 @@ class Command_Response extends Response
if (!empty($this->_temptable)) {
$this->setKey('output', 'array');
}
$this->_completed = $this->isSuccess();
// return $this->isSuccess();
}
@ -165,7 +162,7 @@ class Command_Response extends Response
class SCCPGeneric_Response extends Response
{
protected $_tables;
private $_temptable;
@ -208,7 +205,7 @@ class SCCPGeneric_Response extends Response
$this->_completed = true;
}
}
protected function ConvertTableData($_tablename, $_fkey, $_fields)
{
$_rawtable = $this->Table2Array($_tablename);
@ -278,8 +275,8 @@ class SCCPGeneric_Response extends Response
}
return $result;
}
public function hasTable()
{
if (is_array($this->_tables)) {
@ -291,7 +288,7 @@ class SCCPGeneric_Response extends Response
{
return (is_array($this->_tables)) ? array_keys($this->_tables) : null;
}
public function Table2Array($tablename = '')
{
$result =array();
@ -324,7 +321,7 @@ class SCCPGeneric_Response extends Response
return false;
}
}
public function getTable($tablename)
{
if ($this->hasTable() && array_key_exists($tablename, $this->_tables)) {
@ -349,7 +346,7 @@ class SCCPGeneric_Response extends Response
// $this->getVariable($rawContent, $_fields);
$this->_completed = !$this->isList();
}
public function getResult()
{
if ($this->getKey('JSON') != null) {

View file

@ -55,8 +55,8 @@ class aminterface
$this->_connect_state = false;
$this->_error = array();
$this->_config = array('host' => 'localhost', 'user' => '', 'pass' => '', 'port' => '5038', 'tsoket' => 'tcp://', 'timeout' => 30, 'enabled' => false);
$this->_eventListeners = array();
// $this->_eventFactory = new EventFactoryImpl(\Logger::getLogger('EventFactory'));
// $this->_responseFactory = new ResponseFactoryImpl(\Logger::getLogger('ResponseFactory'));
@ -259,7 +259,7 @@ class aminterface
$response = $this->findResponse($event);
// print_r($response);
// print_r('<br>--- E2 Response Type 2 ----------<br>');
if ($response === false || $response->isComplete()) {
$this->dispatch($event); // не работает
} else {
@ -409,7 +409,7 @@ class aminterface
$listener = $data[0];
$predicate = $data[1];
print_r($data);
if (is_callable($predicate) && !call_user_func($predicate, $message)) {
continue;
}

View file

@ -45,11 +45,11 @@ class extconfigs
$tmp_dt = new \DateTime(null, new \DateTimeZone($index));
$tmp_ofset = $tmp_dt->getOffset();
return $tmp_ofset / 60;
break;
case 'sccp_timezone': // Sccp manafer: 1400 (+ Id) :2007 (+ Id)
$result = array();
if (empty($index)) {
return array('offset' => '00', 'daylight' => '', 'cisco_code' => 'Greenwich');
}
@ -57,7 +57,7 @@ class extconfigs
return $this->get_cisco_time_zone($index);
} else {
$timezone_abbreviations = \DateTimeZone::listAbbreviations();
$tz_tmp = array();
foreach ($timezone_abbreviations as $subArray) {
$tf_idt = array_search($index, array_column($subArray, 'timezone_id'));
@ -109,7 +109,7 @@ class extconfigs
private function get_cisco_time_zone($tzc)
{
if ((empty($tzc)) or (!array_key_exists($tzc, $this->cisco_timezone))) {
// return array('offset' => '00', 'daylight' => '', 'cisco_code' => 'Greenwich');
return array();
@ -464,14 +464,14 @@ class extconfigs
$res['extconfig'] = 'OK';
if (empty($res['sccpdevice'])) {
$res['extconfig'] = ' Options "Sccpdevice" not config ';
$res['extconfig'] = ' Option "Sccpdevice" is not configured ';
}
if (empty($res['sccpline'])) {
$res['extconfig'] = ' Options "Sccpline" not config ';
$res['extconfig'] = ' Option "Sccpline" is not configured ';
}
if (empty($res['extconfigfile'])) {
$res['extconfig'] = 'File extconfig.conf not exist';
$res['extconfig'] = 'File extconfig.conf does not exist';
}
@ -483,10 +483,10 @@ class extconfigs
if (file_exists($dir . '/res_mysql.conf')) {
$res_conf = $cnf_read->getConfig('res_mysql.conf');
if (empty($res_conf[$realm])) {
$res['mysqlconfig'] = 'Not Config in file: res_mysql.conf';
$res['mysqlconfig'] = 'Config not found in file: res_mysql.conf';
} else {
if ($res_conf[$realm]['dbsock'] != $def_bd_config['dbsock']) {
$res['mysqlconfig'] = 'Mysql Soket Error in file: res_mysql.conf';
$res['mysqlconfig'] = 'Mysql Socket Error in file: res_mysql.conf';
}
}
if (empty($res['mysqlconfig'])) {
@ -500,7 +500,7 @@ class extconfigs
$res['mysqlconfig'] = 'Not Config in file: res_config_mysql.conf';
} else {
if ($res_conf[$realm]['dbsock'] != $def_bd_config['dbsock']) {
$res['mysqlconfig'] = 'Mysql Soket Error in file: res_config_mysql.conf';
$res['mysqlconfig'] = 'Mysql Socket Error in file: res_config_mysql.conf';
}
}
if (empty($res['mysqlconfig'])) {

View file

@ -14,6 +14,7 @@ $ast_realtime = $this->srvinterface->sccp_realtime_status();
$ast_realm = (empty($ast_realtime['sccp']) ? '' : 'sccp');
// if there are multiple connections, this will only return the first.
foreach ($ast_realtime as $key => $value) {
if (empty($ast_realm)) {
if ($value['status'] == 'OK') {
@ -61,7 +62,7 @@ if ($db_Schema == 0) {
}
if (empty($ast_realtime)) {
$info['RealTime'] = array('Version' => 'Error', 'about' => '<div class="alert signature alert-danger"> No found Real Time connections</div>');
$info['RealTime'] = array('Version' => 'Error', 'about' => '<div class="alert signature alert-danger"> No RealTime connections found</div>');
} else {
$rt_info = '';
$rt_sccp = 'Failed';
@ -82,7 +83,7 @@ if (empty($ast_realtime)) {
}
if (empty($conf_realtime)) {
$info['ConfigsRealTime'] = array('Version' => 'Error', 'about' => '<div class="alert signature alert-danger"> No found Real Time Configs</div>');
$info['ConfigsRealTime'] = array('Version' => 'Error', 'about' => '<div class="alert signature alert-danger"> Realtime configuration was not found</div>');
} else {
$rt_info = '';
foreach ($conf_realtime as $key => $value) {
@ -135,7 +136,7 @@ if ($test_any == 1) {
//print_r(array_column($timezone_abbreviations, 'timezone_id'));
print_r($Ts_set);
$tz_tmp = array();
foreach ($timezone_abbreviations as $subArray) {
$dddd = array_search($Ts_set, array_column($subArray, 'timezone_id'));
if (!empty($dddd)) {
@ -157,7 +158,7 @@ if ($test_any == 1) {
}
}
}
print_r("<br>");
//print_r($time_set);
print_r($this->sccpvalues['ntp_timezone']);
@ -443,12 +444,12 @@ print(" ");
//print_r($this->dbinterface->info());
if (!empty($this->info_warning)) {
?>
?>
<div class="fpbx-container container-fluid">
<div class="row">
<div class="container">
<h2 style="border:2px solid Tomato;color:Tomato;" >Sccp Manager Warning</h2>
<div class="table-responsive">
<div class="table-responsive">
<br> There are Warning in the SCCP Module:<br><pre>
<?php
foreach ($this->info_warning as $key => $value) {
@ -472,12 +473,12 @@ if (!empty($this->info_warning)) {
}
if (!empty($this->class_error)) {
?>
?>
<div class="fpbx-container container-fluid">
<div class="row">
<div class="container">
<h2 style="border:2px solid Tomato;color:Tomato;" >Diagnostic information about SCCP Manager errors</h2>
<div class="table-responsive">
<div class="table-responsive">
<br> There is an error in the :<br><pre>
<?php print_r($this->class_error); ?>
</pre>
@ -493,7 +494,7 @@ if (!empty($this->class_error)) {
<div class="row">
<div class="container">
<h2>Sccp Manager V.<?php print_r($this->sccp_manager_ver); ?> Info </h2>
<div class="table-responsive">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
@ -517,4 +518,3 @@ foreach ($info as $key => $value) {
</div>
</div>
<?php echo $this->showGroup('sccp_info', 0); ?>