Przeglądaj źródła

Notify clients only once of empty buddy-list

Robin Linus 9 lat temu
rodzic
commit
b66340e1dd
1 zmienionych plików z 9 dodań i 1 usunięć
  1. 9 1
      server/ws-server.js

+ 9 - 1
server/ws-server.js

@@ -126,7 +126,15 @@ exports.create = function(server) {
                     isSystemEvent: true,
                     type: 'buddies'
                 };
-                client.socket.send(msg);
+                if (buddies.length) {
+                    client.socket.send(msg);
+                    client.notifiedEmpty = false;
+                    return;
+                }
+                if (!client.notifiedEmpty) {
+                    client.notifiedEmpty = true;
+                    client.socket.send(msg);
+                }
             });
         });
     }