Skip to content

Instantly share code, notes, and snippets.

@zackproser
Created July 21, 2015 06:02
Show Gist options
  • Save zackproser/c5ccdd718e808b770eb6 to your computer and use it in GitHub Desktop.
Save zackproser/c5ccdd718e808b770eb6 to your computer and use it in GitHub Desktop.
Shows how to check for child processes currently running on our express server - looked up by target number.
/**
* Helper method that determines whether or not a supplied number is currently under attack
*
* @param {String} target - the phone number to check for current attacks
* @return {Boolean} targetIsBeingAttacked - Whether or not the given number is under attack
*/
isTargetBeingAttacked = function(target) {
if (target.charAt(0) == '+' && target.charAt(1) == '1'){
target = target.replace('+1', '');
}
var targetIsBeingAttacked = false;
var currentAttacks = app.get('activeAttacks');
if (!currentAttacks.length) return;
currentAttacks.forEach(function(currentAttack){
if (currentAttack.target_number == target){
targetIsBeingAttacked = true;
}
});
return targetIsBeingAttacked;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment