mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-26 20:52:44 +08:00
修正websocket连接地址
This commit is contained in:
parent
b64168120a
commit
1d58446245
@ -11,6 +11,7 @@ use App\Models\User as UserModel;
|
|||||||
use App\Services\Auth\Api as ApiAuth;
|
use App\Services\Auth\Api as ApiAuth;
|
||||||
use App\Traits\Response as ResponseTrait;
|
use App\Traits\Response as ResponseTrait;
|
||||||
use App\Traits\Security as SecurityTrait;
|
use App\Traits\Security as SecurityTrait;
|
||||||
|
use App\Validators\Validator as AppValidator;
|
||||||
use Phalcon\Mvc\Dispatcher;
|
use Phalcon\Mvc\Dispatcher;
|
||||||
|
|
||||||
class Controller extends \Phalcon\Mvc\Controller
|
class Controller extends \Phalcon\Mvc\Controller
|
||||||
@ -30,6 +31,10 @@ class Controller extends \Phalcon\Mvc\Controller
|
|||||||
$this->setCors();
|
$this->setCors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$validator = new AppValidator();
|
||||||
|
|
||||||
|
$validator->checkSiteStatus();
|
||||||
|
|
||||||
$this->checkRateLimit();
|
$this->checkRateLimit();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -52,4 +57,16 @@ class Controller extends \Phalcon\Mvc\Controller
|
|||||||
return $auth->getCurrentUser();
|
return $auth->getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getSiteInfo()
|
||||||
|
{
|
||||||
|
return $this->getSettings('site');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSettings($section)
|
||||||
|
{
|
||||||
|
$appService = new AppService();
|
||||||
|
|
||||||
|
return $appService->getSettings($section);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ class Controller extends \Phalcon\Mvc\Controller
|
|||||||
* ssl通过nginx转发实现
|
* ssl通过nginx转发实现
|
||||||
*/
|
*/
|
||||||
if ($this->request->isSecure()) {
|
if ($this->request->isSecure()) {
|
||||||
$websocket->connect_url = sprintf('wss://%s/wss', $this->request->getHttpHost());
|
$websocket->connect_url = sprintf('wss://%s/wss', $websocket->connect_address);
|
||||||
} else {
|
} else {
|
||||||
$websocket->connect_url = sprintf('ws://%s', $websocket->connect_address);
|
$websocket->connect_url = sprintf('ws://%s', $websocket->connect_address);
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,26 @@
|
|||||||
namespace App\Validators;
|
namespace App\Validators;
|
||||||
|
|
||||||
use App\Exceptions\Forbidden as ForbiddenException;
|
use App\Exceptions\Forbidden as ForbiddenException;
|
||||||
|
use App\Exceptions\ServiceUnavailable;
|
||||||
|
use App\Exceptions\ServiceUnavailable as ServiceUnavailableException;
|
||||||
use App\Exceptions\Unauthorized as UnauthorizedException;
|
use App\Exceptions\Unauthorized as UnauthorizedException;
|
||||||
|
use App\Services\Service as AppService;
|
||||||
use Phalcon\Di\Injectable;
|
use Phalcon\Di\Injectable;
|
||||||
|
|
||||||
class Validator extends Injectable
|
class Validator extends Injectable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function checkSiteStatus()
|
||||||
|
{
|
||||||
|
$service = new AppService();
|
||||||
|
|
||||||
|
$siteInfo = $service->getSettings('site');
|
||||||
|
|
||||||
|
if ($siteInfo['status'] == 'closed') {
|
||||||
|
throw new ServiceUnavailableException('sys.service_unavailable');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function checkAuthUser($userId)
|
public function checkAuthUser($userId)
|
||||||
{
|
{
|
||||||
if (empty($userId)) {
|
if (empty($userId)) {
|
||||||
|
@ -150,7 +150,7 @@ $config['throttle']['rate_limit'] = 60;
|
|||||||
/**
|
/**
|
||||||
* 客户端ping服务端间隔(秒)
|
* 客户端ping服务端间隔(秒)
|
||||||
*/
|
*/
|
||||||
$config['websocket']['ping_interval'] = 50;
|
$config['websocket']['ping_interval'] = 30;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端连接地址(外部可访问的域名或ip),带端口号
|
* 客户端连接地址(外部可访问的域名或ip),带端口号
|
||||||
|
Loading…
x
Reference in New Issue
Block a user