forked from DGNum/gestioCOF
Add url get method
This commit is contained in:
parent
499c081565
commit
413df0806d
1 changed files with 9 additions and 4 deletions
|
@ -40,13 +40,18 @@ class Websocket {
|
|||
constructor(data) {
|
||||
$.extend(this, this.constructor.default_data, data);
|
||||
}
|
||||
|
||||
listen(handle_func) {
|
||||
var that = this;
|
||||
|
||||
get url() {
|
||||
var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws';
|
||||
var location_host = window.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) {
|
||||
var data = $.extend({}, that.default_msg, JSON.parse(e.data));
|
||||
|
|
Loading…
Reference in a new issue