More work on pre-user session recording. #3064
This commit is contained in:
parent
e6b6bd061e
commit
31e8c12bca
|
@ -129,6 +129,10 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||
if ((typeof sr == 'number') && (sr > 0) && (sr < 1000)) { peer.slowRelay = sr; }
|
||||
}
|
||||
|
||||
// Check session recording
|
||||
var startRecord = false;
|
||||
if ((domain.sessionrecording.onlyselectedusers === true) && (peer.user != null) && (peer.user.flags != null) && ((peer.user.flags & 2) != 0)) { startRecord = true; }
|
||||
startRecording(domain, startRecord, function () {
|
||||
// Indicated we are connected
|
||||
obj.sendToViewer(peer, obj.recordingFile ? 'cr' : 'c');
|
||||
|
||||
|
@ -145,6 +149,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||
|
||||
// Send an updated list of all peers to all viewers
|
||||
obj.sendSessionMetadata();
|
||||
});
|
||||
} else {
|
||||
//console.log('addPeer-agent', obj.nodeid);
|
||||
if (obj.agent != null) { parent.parent.debug('relay', 'DesktopRelay: Error, duplicate agent connection'); return false; }
|
||||
|
@ -253,7 +258,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||
|
||||
// Add a event entry about this recording
|
||||
var basefile = parent.parent.path.basename(filename);
|
||||
var event = { etype: 'relay', action: 'recording', domain: domain.id, nodeid: obj.nodeid, msgid: 7, mshArgs: [obj.sessionLength], msg: "Finished recording session" + (obj.sessionLength ? (', ' + obj.sessionLength + ' second(s)') : ''), filename: basefile, size: obj.recordingFileSize, protocol: 2, icon: obj.icon, name: obj.name, meshid: obj.meshid, userids: obj.userIds, multiplex: true };
|
||||
var event = { etype: 'relay', action: 'recording', domain: domain.id, nodeid: obj.nodeid, msgid: 7, msgArgs: [obj.sessionLength], msg: "Finished recording session" + (obj.sessionLength ? (', ' + obj.sessionLength + ' second(s)') : ''), filename: basefile, size: obj.recordingFileSize, protocol: 2, icon: obj.icon, name: obj.name, meshid: obj.meshid, userids: obj.userIds, multiplex: true };
|
||||
var mesh = parent.meshes[obj.meshid];
|
||||
if (mesh != null) { event.meshname = mesh.name; }
|
||||
if (obj.sessionStart) { event.startTime = obj.sessionStart; event.lengthTime = obj.sessionLength; }
|
||||
|
@ -726,28 +731,10 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||
}
|
||||
}
|
||||
|
||||
function recordingSetup(domain, func) {
|
||||
// Setup session recording
|
||||
if ((domain.sessionrecording == true || ((typeof domain.sessionrecording == 'object') && ((domain.sessionrecording.protocols == null) || (domain.sessionrecording.protocols.indexOf(2) >= 0))))) {
|
||||
|
||||
// Check again to make sure we need to start recording
|
||||
if ((domain.sessionrecording.onlyselecteddevicegroups === true) || (domain.sessionrecording.onlyselectedusers === true)) {
|
||||
var record = false;
|
||||
|
||||
// Check user recording
|
||||
if (domain.sessionrecording.onlyselectedusers === true) {
|
||||
// TODO: Check recording ???
|
||||
}
|
||||
|
||||
// Check device group recording
|
||||
if (domain.sessionrecording.onlyselecteddevicegroups === true) {
|
||||
var mesh = parent.meshes[obj.meshid];
|
||||
if ((mesh.flags != null) && ((mesh.flags & 4) != 0)) { record = true; }
|
||||
}
|
||||
|
||||
if (record == false) { func(false); return; } // Do not record the session
|
||||
}
|
||||
|
||||
function startRecording(domain, start, func) {
|
||||
if ((obj.pendingRecording == 1) || (obj.recordingFile != null)) { func(true); return; } // Check if already recording
|
||||
if (start == false) { func(false); return; } // Just skip this
|
||||
obj.pendingRecording = 1;
|
||||
var now = new Date(Date.now());
|
||||
var recFilename = 'desktopSession' + ((domain.id == '') ? '' : '-') + domain.id + '-' + now.getUTCFullYear() + '-' + parent.common.zeroPad(now.getUTCMonth(), 2) + '-' + parent.common.zeroPad(now.getUTCDate(), 2) + '-' + parent.common.zeroPad(now.getUTCHours(), 2) + '-' + parent.common.zeroPad(now.getUTCMinutes(), 2) + '-' + parent.common.zeroPad(now.getUTCSeconds(), 2) + '-' + obj.nodeid.split('/')[2] + '.mcrec'
|
||||
var recFullFilename = null;
|
||||
|
@ -759,6 +746,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||
recFullFilename = parent.parent.path.join(parent.parent.recordpath, recFilename);
|
||||
}
|
||||
parent.parent.fs.open(recFullFilename, 'w', function (err, fd) {
|
||||
delete obj.pendingRecording;
|
||||
if (err != null) {
|
||||
parent.parent.debug('relay', 'Relay: Unable to record to file: ' + recFullFilename);
|
||||
func(false);
|
||||
|
@ -774,9 +762,28 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||
func(true);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
func(false);
|
||||
}
|
||||
|
||||
function recordingSetup(domain, func) {
|
||||
var record = false;
|
||||
|
||||
// Setup session recording
|
||||
if ((domain.sessionrecording == true || ((typeof domain.sessionrecording == 'object') && ((domain.sessionrecording.protocols == null) || (domain.sessionrecording.protocols.indexOf(2) >= 0))))) {
|
||||
record = true;
|
||||
|
||||
// Check again to make sure we need to start recording
|
||||
if ((domain.sessionrecording.onlyselecteddevicegroups === true) || (domain.sessionrecording.onlyselectedusers === true)) {
|
||||
record = false;
|
||||
|
||||
// Check device group recording
|
||||
if (domain.sessionrecording.onlyselecteddevicegroups === true) {
|
||||
var mesh = parent.meshes[obj.meshid];
|
||||
if ((mesh.flags != null) && ((mesh.flags & 4) != 0)) { record = true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
startRecording(domain, record, func);
|
||||
}
|
||||
|
||||
// Record data to the recording file
|
||||
|
|
|
@ -9944,7 +9944,7 @@
|
|||
if (mode == 3) { eventList = currentUserEvents; }
|
||||
for (var i in eventList) { if (eventList[i].h == h) { xevent = eventList[i]; break; } }
|
||||
if (xevent) {
|
||||
var x = '<div style=overflow-y:auto>';
|
||||
var x = '<div style=overflow-y:auto;max-height:300px>';
|
||||
for (var i in xevent) {
|
||||
if ((i == 'h') || (i == '_id') || (i == 'ids') || (i == 'domain') || (xevent[i] == null) || (typeof xevent[i] == 'object')) continue;
|
||||
x += addHtmlValue3(EscapeHtml(i), EscapeHtml(xevent[i]));
|
||||
|
|
Loading…
Reference in New Issue