Use location.name instead of _server_name

This makes sure that even when there is a forward through a router, VirtualBox, an SSH tunnel,
the websocket connections will go to the right place instead of simply failing.
This commit is contained in:
Christian Sturm
2018-12-28 19:40:04 +01:00
committed by GitHub
parent 04446228f8
commit fda2ed7d7b

View File

@@ -2606,7 +2606,7 @@ var clonos={
wsconnect:function()
{
this.client_id=Math.random(10000); // поменять на сессию
this.socket = new WebSocket("ws://"+_server_name+":8023/clonos"+location.pathname);
this.socket = new WebSocket("ws://"+location.hostname+":8023/clonos"+location.pathname);
$(this.socket).on('open',$.proxy(this.wsopen,this))
.on('close',$.proxy(this.wsclose,this))
.on('error',$.proxy(this.wserror,this))
@@ -3251,7 +3251,7 @@ graphs={
{
console.log('Соединяемся по сокету');
this.client_id=this.name;
socket = new WebSocket("ws://"+_server_name+":8024/graph"+location.pathname+"client-"+Math.random());
socket = new WebSocket("ws://"+location.hostname+":8024/graph"+location.pathname+"client-"+Math.random());
$(socket).on('open',$.proxy(this.wsopen,this))
.on('close',$.proxy(this.wsclose,this))
.on('error',$.proxy(this.wserror,this))
@@ -3598,4 +3598,4 @@ function ws_debug(){
$(window).on('load',function(){clonos.start();});
$(window).on('unload',function(){}); /* эта функция заставляет FireFox запускать JS-функции при нажатии кнопки «Назад»
http://stackoverflow.com/questions/2638292/after-travelling-back-in-firefox-history-javascript-wont-run */
$(function(){clonos.loadData('getJsonPage',$.proxy(clonos.onLoadData,clonos));});
$(function(){clonos.loadData('getJsonPage',$.proxy(clonos.onLoadData,clonos));});