From c13e8222bd342f7def26055b424431a1b767fe3e Mon Sep 17 00:00:00 2001 From: Odei Maiz <33152403+odeimaiz@users.noreply.github.com> Date: Mon, 21 Oct 2024 08:13:00 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20[Frontend]=20Reuse=20client=5Fse?= =?UTF-8?q?ssion=5Fid=20from=20socket's=20query=20instead=20of=20creating?= =?UTF-8?q?=20a=20new=20one=20(#6564)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/source/class/osparc/utils/Utils.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/utils/Utils.js b/services/static-webserver/client/source/class/osparc/utils/Utils.js index fdf69de394b..98d6f06dd83 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Utils.js +++ b/services/static-webserver/client/source/class/osparc/utils/Utils.js @@ -1033,11 +1033,13 @@ qx.Class.define("osparc.utils.Utils", { // Function that creates a unique tabId even for duplicated tabs getClientSessionID: function() { const getUniqueSessionId = () => { - const uuid = osparc.utils.Utils.uuidV4(); + // before creating a new one, check if the websocket has it set + const webSocket = osparc.wrapper.WebSocket.getInstance().getSocket(); + const clientSessionId = webSocket ? webSocket.io.engine.opts.query["client_session_id"] : osparc.utils.Utils.uuidV4(); // Set window.name. This property is persistent on window reloads, but it doesn't get copied in a duplicated tab - window.name = uuid; - sessionStorage.setItem("clientsessionid", uuid); - return uuid; + window.name = clientSessionId; + sessionStorage.setItem("clientsessionid", clientSessionId); + return clientSessionId; }; let uniqueSessionId = sessionStorage.getItem("clientsessionid");