Created
July 21, 2015 06:02
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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