From 7935f8a3ced34f51db361fb2aafbf22ea3b9f84b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 31 Mar 2020 16:27:41 +0200 Subject: [PATCH] Add websocket shorcut --- assets/js/common/shorcuts.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/assets/js/common/shorcuts.js b/assets/js/common/shorcuts.js index f8dd983a..ad1b0539 100644 --- a/assets/js/common/shorcuts.js +++ b/assets/js/common/shorcuts.js @@ -17,6 +17,21 @@ function api(uri, args, withLogin){ return ComunicWeb.common.api.exec(uri, args, withLogin); } +/** + * Perform a requests through the WebSocket + * + * @param {String} title The title of the request + * @param {Object} data Data to include to request + * @return {Promise} + */ +function ws(title, data = {}) { + + if(typeof data != "object") + throw new Error("Invalid data for websocket request!"); + + return UserWebSocket.SendRequest(title, data); +} + /** * Create a quick language access function shorcut *