瀏覽代碼

Notify clients only once of empty buddy-list

Robin Linus 9 年之前
父節點
當前提交
b66340e1dd
共有 1 個文件被更改,包括 9 次插入1 次删除
  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);
+                }
             });
         });
     }