Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let buddyAdded = false;
- replicaArr = _.keys(ReplicaList);
- Promise.each(replicaArr, function(replicaname) {
- if (!buddyAdded) {
- Player.count({
- 'buddyList': replicaname
- }, function(err, result) {
- if (err) {
- } else if (result < 990) {
- Player.update({
- '_id': buddyObj.buddyId
- }, {
- 'buddyList': replicaname
- }, function(err) {
- if (err) {
- } else {
- ReplicaList[replicaname].send(buddyObj);
- buddyAdded = true;
- // success stop here and skip all the other array elements
- return;
- }
- });
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement