Created
July 21, 2015 06:05
-
-
Save zackproser/421f3f6866a88f10b976 to your computer and use it in GitHub Desktop.
How to look up a child process by a property - and kill it.
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
/** | |
* Finds a currently running attack by phone number and terminates it in response to an admin stop attack request | |
* | |
* @param {String} requesting_admin - The phone number of the admin requesting a stop | |
* @param {String} target_number - The phone number that should not be attacked anymore | |
* @return void | |
*/ | |
handleAdminStopRequest = function(requesting_admin, target_number) { | |
var currentAttacks = app.get('activeAttacks'); | |
var foundAttack = false; | |
if (!currentAttacks.length) return; | |
currentAttacks.forEach(function(currentAttack){ | |
if (currentAttack.target_number == target_number){ | |
foundAttack = currentAttack; | |
} | |
}); | |
if (foundAttack){ | |
foundAttack.kill(); | |
sendResponseSMS(requesting_admin, 'Successfully terminated CatFacts Attack on ' + target_number); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment