Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function jsonRpc(url, fct_name, params, settings) {
settings = settings || {};
var fallback = _jsonRpc.bind(this, url, fct_name, params, settings);
// check for relative url
if (websocket.ws && websocket.ws.enabled()) {
return genericJsonRpc(fct_name, params, settings, function(rpc) {
return websocket.ws.send(_.extend({}, settings, {
path: url,
rpc: rpc
}));
});
}
return fallback();
}
setup: function() {
this._super.apply(this, arguments);
if (websocket.ws) websocket.ws.destroy();
var uri = this.origin.replace('http://', 'ws://').replace('https://', 'wss://');
if (odoo.debug) {
uri += '?debug=' + $.deparam($.param.querystring()).debug;
}
websocket.ws = new WebSocket(uri);
}
});
return genericJsonRpc(fct_name, params, settings, function(rpc) {
return websocket.ws.send(_.extend({}, settings, {
path: url,
rpc: rpc
}));
});
}