1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

wait 5 sec after record and also pass message back (#5508)

* wait 5 sec after record and also pass message back

Signed-off-by: si458 <simonsmith5521@gmail.com>

* add connect-flash package (#5509)

Signed-off-by: si458 <simonsmith5521@gmail.com>

---------

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2023-11-05 04:39:02 +00:00 committed by GitHub
parent 7b016eac58
commit 4790f40179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 44 deletions

View file

@ -13,27 +13,15 @@ var worker = null;
const NodeJSVer = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
var directRun = (require.main === module);
function log() { if (directRun) { console.log(...arguments); } /*else { if (worker != null) { worker.parentPort.postMessage({ msg: arguments[0] }); } } */ }
function log2() { if (directRun) { console.log(...arguments); } else { process.send(...arguments); } /*else { if (worker != null) { worker.parentPort.postMessage({ msg: arguments[0] }); } } */ }
if (directRun && (NodeJSVer >= 12)) { const xworker = require('worker_threads'); try { if (xworker.isMainThread == false) { worker = xworker; } } catch (ex) { log(ex); } }
function start() { startEx(process.argv); }
if (directRun) { setup(); }
function setup() { InstallModules(['image-size'], start); }
function start() { startEx(process.argv); }
function startEx(argv) {
if (argv.length > 2) { indexFile(argv[2]); } else {
log("MeshCentral Session Recodings Processor");
log("This tool will index a .mcrec file so that the player can seek thru the file.");
log("");
log(" Usage: node mcrec [file]");
}
}
function indexFile(infile) {
var state = { recFileName: null, recFile: null, recFileSize: 0, recFilePtr: 0 };
if (fs.existsSync(infile) == false) { log("Missing file: " + infile); return; }
if (fs.existsSync(infile) == false) { log2("Missing file: " + infile); return; }
state.recFileName = infile;
state.recFileSize = fs.statSync(infile).size;
if (state.recFileSize < 32) { log("Invalid file: " + infile); return; }
if (state.recFileSize < 32) { log2("Invalid file size: " + infile); return; }
log("Processing file: " + infile + ", " + state.recFileSize + " bytes.");
state.recFile = fs.openSync(infile, 'r+');
state.indexTime = 10; // Interval between indexes in seconds
@ -43,8 +31,8 @@ function indexFile(infile) {
state.height = 0;
state.basePtr = null;
readLastBlock(state, function (state, result, time, extras) {
if (result == false) { log("Invalid file: " + infile); return; }
if (extras != null) { log("File already indexed: " + infile); return; }
if (result == false) { log2("Invalid file: " + infile); return; }
if (extras != null) { log2("File already indexed: " + infile); return; }
state.lastTimeStamp = time;
readNextBlock(state, processBlock);
});
@ -68,7 +56,7 @@ function processBlock(state, block, err) {
// Error reading the next block, exit now.
fs.close(state.recFile, function () {
for (var i in state) { delete state[i]; } // Clear the state.
log("Error.");
log2("Error.");
});
return;
}
@ -77,7 +65,7 @@ function processBlock(state, block, err) {
writeIndex(state, function () {
fs.close(state.recFile, function () {
for (var i in state) { delete state[i]; } // Clear the state.
log("Done.");
log2("Done.");
});
});
return;
@ -96,8 +84,8 @@ function processBlock(state, block, err) {
if (block.type == 1) {
// Metadata
state.metadata = JSON.parse(block.data.toString());
if (state.metadata.indexInterval != null) { log("This file is already indexed."); return; }
if (state.metadata.protocol != 2) { log("Only remote desktop sessions can currently be indexed."); return; }
if (state.metadata.indexInterval != null) { log2("This file is already indexed."); return; }
if (state.metadata.protocol != 2) { log2("Only remote desktop sessions can currently be indexed."); return; }
state.metadataFlags = block.flags;
state.metadataTime = block.time;
state.recFileProtocol = state.metadata.protocol;
@ -329,6 +317,18 @@ function InstallModule(modulename, func, tag1, tag2) {
});
}
function setup() { InstallModules(['image-size'], start); }
function start() { startEx(process.argv); }
function startEx(argv) {
if (argv.length > 2) { indexFile(argv[2]); } else {
log("MeshCentral Session Recodings Processor");
log("This tool will index a .mcrec file so that the player can seek thru the file.");
log("");
log(" Usage: node mcrec [file]");
}
}
if (directRun) { setup(); }
// Export table
module.exports.startEx = startEx;
module.exports.indexFile = indexFile;