修正:websocket区分http和https两种连接方式。

pull/105/head
Apex Liu 2018-03-23 17:05:15 +08:00
parent 9425afc3eb
commit 396312ece1
1 changed files with 7 additions and 1 deletions

View File

@ -457,7 +457,13 @@ $app.init_ws = function () {
delete $app.ws; delete $app.ws;
var _sid = Cookies.get('_sid'); var _sid = Cookies.get('_sid');
$app.ws = new WebSocket('ws://' + location.host + '/ws/' + _sid); console.log(location);
console.log(location.host);
if(location.protocol === 'http') {
$app.ws = new WebSocket('ws://' + location.host + '/ws/' + _sid);
} else {
$app.ws = new WebSocket('wss://' + location.host + '/ws/' + _sid);
}
$app.ws.onopen = function (e) { $app.ws.onopen = function (e) {
$app.ws.send('{"method": "request", "param": "sys_status"}'); $app.ws.send('{"method": "request", "param": "sys_status"}');