Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. let buddyAdded = false;
  2. replicaArr = _.keys(ReplicaList);
  3. Promise.each(replicaArr, function(replicaname) {
  4. if (!buddyAdded) {
  5. Player.count({
  6. 'buddyList': replicaname
  7. }, function(err, result) {
  8. if (err) {
  9.  
  10. } else if (result < 990) {
  11.  
  12. Player.update({
  13. '_id': buddyObj.buddyId
  14. }, {
  15. 'buddyList': replicaname
  16. }, function(err) {
  17. if (err) {
  18.  
  19. } else {
  20. ReplicaList[replicaname].send(buddyObj);
  21. buddyAdded = true;
  22. // success stop here and skip all the other array elements
  23. return;
  24. }
  25. });
  26. }
  27. });
  28. }
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement