mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2026-04-18 15:22:16 +00:00
Notify clients only if buddies change
This commit is contained in:
@@ -120,24 +120,22 @@ exports.create = function(server) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}, []);
|
}, []);
|
||||||
|
var currState = hash(buddies.toString());
|
||||||
|
var socket = client.socket;
|
||||||
//protocol
|
//protocol
|
||||||
var msg = {
|
var msg = {
|
||||||
buddies: buddies,
|
buddies: buddies,
|
||||||
isSystemEvent: true,
|
isSystemEvent: true,
|
||||||
type: 'buddies'
|
type: 'buddies'
|
||||||
};
|
};
|
||||||
if (buddies.length) {
|
if (currState !== socket.lastState) {
|
||||||
client.socket.send(msg);
|
socket.send(msg);
|
||||||
client.notifiedEmpty = false;
|
socket.lastState = currState;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!client.notifiedEmpty) {
|
|
||||||
client.notifiedEmpty = true;
|
|
||||||
client.socket.send(msg);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(notifyBuddiesX, 5000);
|
setInterval(notifyBuddiesX, 3000);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user