代码规范

This commit is contained in:
thinkphp
2016-01-12 08:16:33 +08:00
parent 7e7fc8639c
commit 57a3a36c78

View File

@@ -17,7 +17,7 @@ class Socket
'show_included_files' => false,
'error_handler' => false,
//日志强制记录到配置的client_id
'force_client_ids'=>array(),
'force_client_ids' => [],
//限制允许读取日志的client_id
'allow_client_ids' => [],
];
@@ -30,7 +30,7 @@ class Socket
'big' => 'font-size:20px;color:red;',
];
protected $_allowForceClientIds = array(); //配置强制推送且被授权的client_id
protected $_allowForceClientIds = []; //配置强制推送且被授权的client_id
/**
* 架构函数
@@ -103,9 +103,7 @@ class Socket
$client_id = '';
}
if(!empty($this->_allowForceClientIds))
{
if (!empty($this->_allowForceClientIds)) {
//强制推送到多个client_id
foreach ($this->_allowForceClientIds as $force_client_id) {
$client_id = $force_client_id;
@@ -117,7 +115,6 @@ class Socket
}
/**
* 发送给指定客户端
* @author Zjmainstay
@@ -126,7 +123,8 @@ class Socket
* @param $logs
* @param $force_client_id
*/
protected function sendToClient($tabid, $client_id, $logs, $force_client_id) {
protected function sendToClient($tabid, $client_id, $logs, $force_client_id)
{
$logs = array(
'tabid' => $tabid,
'client_id' => $client_id,
@@ -138,23 +136,19 @@ class Socket
$this->send($this->config['host'], $msg, $address);
}
protected static function check()
{
if(!$this->config['enable'])
{
if (!$this->config['enable']) {
return false;
}
$tabid = $this->getClientArg('tabid');
//是否记录日志的检查
if(!$tabid && !$this->config['force_client_ids'])
{
if (!$tabid && !$this->config['force_client_ids']) {
return false;
}
//用户认证
$allow_client_ids = $this->config['allow_client_ids'];
if(!empty($allow_client_ids))
{
if (!empty($allow_client_ids)) {
//通过数组交集得出授权强制推送的client_id
$this->_allowForceClientIds = array_intersect($allow_client_ids, $this->config['force_client_ids']);
if (!$tabid && count($this->_allowForceClientIds)) {
@@ -162,13 +156,10 @@ class Socket
}
$client_id = $this->getClientArg('client_id');
if(!in_array($client_id,$allow_client_ids))
{
if (!in_array($client_id, $allow_client_ids)) {
return false;
}
}
else
{
} else {
$this->_allowForceClientIds = $this->config['force_client_ids'];
}
return true;