Add url get method
This commit is contained in:
parent
499c081565
commit
413df0806d
|
@ -41,12 +41,17 @@ class Websocket {
|
||||||
$.extend(this, this.constructor.default_data, data);
|
$.extend(this, this.constructor.default_data, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
listen(handle_func) {
|
get url() {
|
||||||
var that = this;
|
|
||||||
var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws';
|
var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws';
|
||||||
var location_host = window.location.host;
|
var location_host = window.location.host;
|
||||||
var location_url = window.location.pathname.startsWith('/gestion/') ? location_host + '/gestion' : location_host;
|
var location_url = window.location.pathname.startsWith('/gestion/') ? location_host + '/gestion' : location_host;
|
||||||
var socket = new ReconnectingWebSocket(websocket_protocol+"://" + location_url + this.relative_url);
|
|
||||||
|
return websocket_protocol+"://" + location_url + this.relative_url ;
|
||||||
|
}
|
||||||
|
|
||||||
|
listen(handle_func) {
|
||||||
|
var that = this;
|
||||||
|
var socket = new ReconnectingWebSocket(this.url);
|
||||||
|
|
||||||
socket.onmessage = function(e) {
|
socket.onmessage = function(e) {
|
||||||
var data = $.extend({}, that.default_msg, JSON.parse(e.data));
|
var data = $.extend({}, that.default_msg, JSON.parse(e.data));
|
||||||
|
|
Loading…
Reference in a new issue