1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-21 07:26:39 +08:00

修正websocket连接地址

This commit is contained in:
koogua 2021-10-03 11:55:22 +08:00
parent 1f46f35a42
commit 6495cbfbe0
6 changed files with 11 additions and 4 deletions

View File

@ -49,8 +49,12 @@ class PublicController extends Controller
$content = [];
/**
* ssl通过nginx转发实现
*/
if ($this->request->isSecure()) {
$content['connect_url'] = sprintf('wss://%s/wss', $this->request->getHttpHost());
list($domain) = explode(':', $websocket->connect_address);
$websocket['connect_url'] = sprintf('wss://%s/wss', $domain);
} else {
$content['connect_url'] = sprintf('ws://%s', $websocket->connect_address);
}

View File

@ -147,7 +147,8 @@ class Controller extends \Phalcon\Mvc\Controller
* ssl通过nginx转发实现
*/
if ($this->request->isSecure()) {
$websocket->connect_url = sprintf('wss://%s/wss', $websocket->connect_address);
list($domain) = explode(':', $websocket->connect_address);
$websocket->connect_url = sprintf('wss://%s/wss', $domain);
} else {
$websocket->connect_url = sprintf('ws://%s', $websocket->connect_address);
}

View File

@ -145,7 +145,7 @@ class ImController extends Controller
}
/**
* @Post("/notice/read", name="home.im.read_notice")
* @Get("/notice/read", name="home.im.read_notice")
*/
public function readNoticeAction()
{

View File

@ -13,6 +13,7 @@ layui.use(['jquery', 'form', 'helper'], function () {
console.log('socket connect success');
setInterval(function () {
socket.send('ping');
console.log('ping...');
}, 1000 * parseInt(window.im.ws.ping_interval));
};

View File

@ -22,6 +22,7 @@ layui.use(['jquery', 'layim'], function () {
console.log('socket connect success');
setInterval(function () {
socket.send('ping');
console.log('ping...');
}, 1000 * parseInt(window.im.ws.ping_interval));
};

View File

@ -42,7 +42,7 @@ layui.use(['jquery', 'layer', 'laypage'], function () {
}
function readNotices() {
$.post('/im/notice/read');
$.get('/im/notice/read');
}
var action = {