mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 22:17:31 +03:00
Added slowRelay debug option to desktop multiplexor
This commit is contained in:
parent
366ccff63b
commit
40683cd28c
@ -107,6 +107,13 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||||||
peer.sendQueue = [];
|
peer.sendQueue = [];
|
||||||
peer.paused = false;
|
peer.paused = false;
|
||||||
|
|
||||||
|
// Setup slow relay is requested. This will show down sending any data to this viewer.
|
||||||
|
if ((peer.req.query.slowrelay != null)) {
|
||||||
|
var sr = null;
|
||||||
|
try { sr = parseInt(peer.req.query.slowrelay); } catch (ex) { }
|
||||||
|
if ((typeof sr == 'number') && (sr > 0) && (sr < 1000)) { peer.slowRelay = sr; }
|
||||||
|
}
|
||||||
|
|
||||||
// Indicated we are connected
|
// Indicated we are connected
|
||||||
obj.sendToViewer(peer, obj.recordingFile ? 'cr' : 'c');
|
obj.sendToViewer(peer, obj.recordingFile ? 'cr' : 'c');
|
||||||
|
|
||||||
@ -268,7 +275,11 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||||||
viewer.sendQueue.push(data);
|
viewer.sendQueue.push(data);
|
||||||
} else {
|
} else {
|
||||||
viewer.sending = true;
|
viewer.sending = true;
|
||||||
viewer.ws.send(data, function () { sendViewerNext(viewer); });
|
if (viewer.slowRelay) {
|
||||||
|
setTimeout(function () { try { viewer.ws.send(data, function () { sendViewerNext(viewer); }); } catch (ex) { } }, viewer.slowRelay);
|
||||||
|
} else {
|
||||||
|
try { viewer.ws.send(data, function () { sendViewerNext(viewer); }); } catch (ex) { }
|
||||||
|
}
|
||||||
|
|
||||||
// Flow control, pause the agent if needed
|
// Flow control, pause the agent if needed
|
||||||
obj.viewersSendingCount++;
|
obj.viewersSendingCount++;
|
||||||
@ -282,7 +293,11 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||||||
if (viewer.sendQueue.length > 0) {
|
if (viewer.sendQueue.length > 0) {
|
||||||
// Send from the pending send queue
|
// Send from the pending send queue
|
||||||
if (viewer.sending == false) { viewer.sending = true; obj.viewersSendingCount++; }
|
if (viewer.sending == false) { viewer.sending = true; obj.viewersSendingCount++; }
|
||||||
viewer.ws.send(viewer.sendQueue.shift(), function () { sendViewerNext(viewer); });
|
if (viewer.slowRelay) {
|
||||||
|
setTimeout(function () { try { viewer.ws.send(viewer.sendQueue.shift(), function () { sendViewerNext(viewer); }); } catch (ex) { } }, viewer.slowRelay);
|
||||||
|
} else {
|
||||||
|
try { viewer.ws.send(viewer.sendQueue.shift(), function () { sendViewerNext(viewer); }); } catch (ex) { }
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (viewer.dataPtr != null) {
|
if (viewer.dataPtr != null) {
|
||||||
// Send the next image
|
// Send the next image
|
||||||
@ -291,7 +306,11 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||||||
viewer.lastImageNumberSent = viewer.dataPtr;
|
viewer.lastImageNumberSent = viewer.dataPtr;
|
||||||
//if ((image.next != null) && ((viewer.dataPtr + 1) != image.next)) { console.log('SVIEW-S2', viewer.dataPtr, image.next); } // DEBUG
|
//if ((image.next != null) && ((viewer.dataPtr + 1) != image.next)) { console.log('SVIEW-S2', viewer.dataPtr, image.next); } // DEBUG
|
||||||
viewer.dataPtr = image.next;
|
viewer.dataPtr = image.next;
|
||||||
viewer.ws.send(image.data, function () { sendViewerNext(viewer); });
|
if (viewer.slowRelay) {
|
||||||
|
setTimeout(function () { try { viewer.ws.send(image.data, function () { sendViewerNext(viewer); }); } catch (ex) { } }, viewer.slowRelay);
|
||||||
|
} else {
|
||||||
|
try { viewer.ws.send(image.data, function () { sendViewerNext(viewer); }); } catch (ex) { }
|
||||||
|
}
|
||||||
|
|
||||||
// Flow control, pause the agent if needed
|
// Flow control, pause the agent if needed
|
||||||
if (viewer.sending == false) {
|
if (viewer.sending == false) {
|
||||||
@ -478,8 +497,6 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||||||
|
|
||||||
//console.log('Adding Image ' + obj.counter, x, y, dimensions.width, dimensions.height);
|
//console.log('Adding Image ' + obj.counter, x, y, dimensions.width, dimensions.height);
|
||||||
|
|
||||||
var skips = [];
|
|
||||||
|
|
||||||
// Update the screen with the correct pointers.
|
// Update the screen with the correct pointers.
|
||||||
for (var i = 0; i < sw; i++) {
|
for (var i = 0; i < sw; i++) {
|
||||||
for (var j = 0; j < sh; j++) {
|
for (var j = 0; j < sh; j++) {
|
||||||
@ -497,13 +514,11 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
|||||||
delete obj.imagesCounters[oi];
|
delete obj.imagesCounters[oi];
|
||||||
|
|
||||||
// If any viewers are currently on image "oi" must be moved to "d.next"
|
// If any viewers are currently on image "oi" must be moved to "d.next"
|
||||||
for (var l in obj.viewers) { const v = obj.viewers[l]; if (v.dataPtr == oi) { skips.push(oi); v.dataPtr = d.next; } }
|
for (var l in obj.viewers) { const v = obj.viewers[l]; if (v.dataPtr == oi) { v.dataPtr = d.next; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skips.length > 0) { console.log('SKIPS', skips.length); }
|
|
||||||
|
|
||||||
// Any viewer on dataPtr null, change to this image
|
// Any viewer on dataPtr null, change to this image
|
||||||
for (var i in obj.viewers) {
|
for (var i in obj.viewers) {
|
||||||
const v = obj.viewers[i];
|
const v = obj.viewers[i];
|
||||||
|
@ -42,6 +42,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort, au
|
|||||||
var url2, url = window.location.protocol.replace('http', 'ws') + '//' + window.location.host + window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) + '/meshrelay.ashx?browser=1&p=' + obj.protocol + '&nodeid=' + nodeid + '&id=' + obj.tunnelid;
|
var url2, url = window.location.protocol.replace('http', 'ws') + '//' + window.location.host + window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) + '/meshrelay.ashx?browser=1&p=' + obj.protocol + '&nodeid=' + nodeid + '&id=' + obj.tunnelid;
|
||||||
//if (serverPublicNamePort) { url2 = window.location.protocol.replace('http', 'ws') + '//' + serverPublicNamePort + '/meshrelay.ashx?id=' + obj.tunnelid; } else { url2 = url; }
|
//if (serverPublicNamePort) { url2 = window.location.protocol.replace('http', 'ws') + '//' + serverPublicNamePort + '/meshrelay.ashx?id=' + obj.tunnelid; } else { url2 = url; }
|
||||||
if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; }
|
if ((authCookie != null) && (authCookie != '')) { url += '&auth=' + authCookie; }
|
||||||
|
if ((urlargs != null) && (urlargs.slowrelay != null)) { url += '&slowrelay=' + urlargs.slowrelay; }
|
||||||
obj.nodeid = nodeid;
|
obj.nodeid = nodeid;
|
||||||
obj.connectstate = 0;
|
obj.connectstate = 0;
|
||||||
obj.socket = new WebSocket(url);
|
obj.socket = new WebSocket(url);
|
||||||
|
Loading…
Reference in New Issue
Block a user