commit 1bce467a7ce48d32aff53350c6482ab411efea66
parent f2a48823d10e42788a2853d9fbfd89c142cc59e8
Author: Robin Linus <robin_woll@capira.de>
Date: Wed, 30 Dec 2015 16:50:59 +0100
Notify clients only if buddies change
Diffstat:
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/server/ws-server.js b/server/ws-server.js
@@ -120,24 +120,22 @@ exports.create = function(server) {
}
return result;
}, []);
+ var currState = hash(buddies.toString());
+ var socket = client.socket;
//protocol
var msg = {
buddies: buddies,
isSystemEvent: true,
type: 'buddies'
};
- if (buddies.length) {
- client.socket.send(msg);
- client.notifiedEmpty = false;
+ if (currState !== socket.lastState) {
+ socket.send(msg);
+ socket.lastState = currState;
return;
}
- if (!client.notifiedEmpty) {
- client.notifiedEmpty = true;
- client.socket.send(msg);
- }
});
});
}
- setInterval(notifyBuddiesX, 5000);
+ setInterval(notifyBuddiesX, 3000);
};