Cloud Require Implemented

This commit is contained in:
Luis Fernando Molina committed 2018-05-23 10:09:11 +02:00
1 parent 3295e91d5f
commit a14a7f655f
3 files changed
+85 -4

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
function newCloudRequire(BOT, DEBUG_MODULE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
const MODULE_NAME = "Cloud Require";
let bot = BOT;
const logger = DEBUG_MODULE.newDebugLog();
logger.bot = bot;
logger.fileName = MODULE_NAME;
logger.initialize();
let thisObject = {
requireBot: requireBot,
requireCommons: requireCommons
};
return thisObject;
function requireBot(pCloudStorage, pProcessConfig, callBackFunction) {
try {
if (FULL_LOG === true) { logger.write("[INFO] requireBot -> Entering function."); }
let filePath = "Bots" + "/" + bot.devTeam + "/" + bot.repo + "/" + pProcessConfig.name + "/" + "User.Bot.js";
downloadModule(filePath, onDownloaded)
function onDownloaded(pModule) {
callBackFunction(global.DEFAULT_OK_RESPONSE, pModule);
return;
}
} catch (err) {
logger.write("[ERROR] requireBot -> err = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
function requireCommons(pCloudStorage, callBackFunction) {
try {
if (FULL_LOG === true) { logger.write("[INFO] requireCommons -> Entering function."); }
let filePath = bot.devTeam + "/" + bot.repo + "/" + "Commons.js";
downloadModule(filePath, onDownloaded)
function onDownloaded(pModule) {
callBackFunction(global.DEFAULT_OK_RESPONSE, pModule);
return;
}
} catch (err) {
logger.write("[ERROR] requireCommons -> err = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
};
+14 -4
View File
@@ -128,20 +128,30 @@ function webRequire(pModulePath) {
MODULE.newDataDependencies = newDataDependencies;
return MODULE;
}
case './CloudRequire': {
let MODULE = {};
MODULE.newCloudRequire = newCloudRequire;
return MODULE;
}
default: {
console.log(pModulePath + " not found. ");
}
}
}
function downloadModule(pPath) {
function downloadModule(pPath, callBackFunction) {
/* We will need this to load individual bots modules. */
Requirejs(["Scripts/DummyWeb"], function (DummyWeb) {
console.log("Dummy Web Loaded");
});
Requirejs([pPath], onRequired);
function onRequired(pModule) {
console.log(pPath + " downloaded.");
callBackFunction(pModule);
}
}
+3
View File
@@ -32,6 +32,9 @@
<Compile Include="AccumulatedVolumeBar.js" />
<Compile Include="Animation.js" />
<Compile Include="Azure\azure-storage.blob.js" />
<Compile Include="CloudVM\CloudRequire.js">
<SubType>Code</SubType>
</Compile>
<Compile Include="Server\Permissions.js">
<SubType>Code</SubType>
</Compile>