fixup! [DeviceHome] Upgrade to v1.0.8 28/263228/1 submit/tizen/20210830.021041 submit/tizen/20210830.160021
authorYoungsoo Choi <kenshin.choi@samsung.com>
Mon, 30 Aug 2021 01:59:25 +0000 (18:59 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Mon, 30 Aug 2021 02:01:01 +0000 (19:01 -0700)
- Don't encrypt message mutiple times in a loop

Change-Id: I24b58a2042d78924e07ccc0ec0ac251e067dfbad
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
device_home/service/relay-server.js

index 3bd650d..a59b5ac 100755 (executable)
@@ -77,16 +77,17 @@ var OnReceived = function (msg) {
         if (id === TO_ALL) {
             console.log(`${TAG_HOST}[OnReceived] Send message to all web sockets`);
             console.log(`${TAG_HOST}[OnReceived] remoteClients length : ${remoteClients[pkgId].length}`);
+            let encryped = '';
             for (let client of remoteClients[pkgId]) {
                 if (secure) {
-                    msg = encrypt(msg, client, pkgId, globalClientPublicKeys);
-                    if (msg === false || msg === null) {
+                    encryped = encrypt(msg, client, pkgId, globalClientPublicKeys);
+                    if (encryped === false || encryped === null) {
                         console.log(`${TAG_HOST}[OnReceived] Failed to encrypt message!`);
                         return;
                     }
                 }
-                console.log(`${TAG_HOST}[OnReceived] msg : ${msg}`);
-                client.emit('d2d_message', msg);
+                console.log(`${TAG_HOST}[OnReceived] msg : ${encryped}`);
+                client.emit('d2d_message', encryped);
             }
         } else {
             console.log(`${TAG_HOST}[OnReceived] Send message to a web socket #${id}`);