From e267926725fa9e03f6b398398eb3212946d3588b Mon Sep 17 00:00:00 2001 From: EdgarPironti Date: Thu, 19 Nov 2015 20:03:27 -0800 Subject: [PATCH] JSON computing --- examples/acScripts/playbackAgents.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/acScripts/playbackAgents.js b/examples/acScripts/playbackAgents.js index 93b563d497..c50c727277 100644 --- a/examples/acScripts/playbackAgents.js +++ b/examples/acScripts/playbackAgents.js @@ -51,13 +51,25 @@ function getAction(channel, message, senderID) { print("I'm the agent " + id + " and I received this: ID: " + command.id_key + " Action: " + command.action_key + " URL: " + command.clip_url_key); if (command.id_key == id || command.id_key == -1) { - if (command.action_key === 6) + if (command.action_key === 6) { clip_url = command.clip_url_key; - - // If the id is -1 (broadcast) and the action is 6, in the url should be the performance file - // with all the clips recorded in a session (not just the single clip url). - // It has to be computed here in order to retrieve the url for the single agent. - // Checking the id we can assign the correct url to the correct agent. + + // If the id is -1 (broadcast) and the action is 6, in the url should be the performance file + // with all the clips recorded in a session (not just the single clip url). + // It has to be computed here in order to retrieve the url for the single agent. + // Checking the id we can assign the correct url to the correct agent. + + if (command.id_key == -1) { + Assets.downloadData(clip_url, function (data) { + var myJSONObject = JSON.parse(data); + var hash = myJSONObject.results[id].hashATP; + }); + + Assets.downloadData(hash, function (data) { + clip_url = JSON.parse(data); + }); + } + } action = command.action_key; print("That command was for me!");