Added new desktop display location/size command support.

This commit is contained in:
Ylian Saint-Hilaire 2021-05-16 12:44:49 -07:00
parent e97e844c82
commit ae936654a4
2 changed files with 19 additions and 1 deletions

View File

@ -54,7 +54,8 @@ MNG_FILEDELETEREC = 62, // Same as MNG_FILEDELETE but recursive
MNG_USERCONSENT = 63, // Used to notify management console of user consent state MNG_USERCONSENT = 63, // Used to notify management console of user consent state
MNG_DEBUG = 64, // Debug/Logging Message for ILibRemoteLogging MNG_DEBUG = 64, // Debug/Logging Message for ILibRemoteLogging
MNG_ERROR = 65, MNG_ERROR = 65,
MNG_ENCAPSULATE_AGENT_COMMAND = 70 MNG_ENCAPSULATE_AGENT_COMMAND = 70,
MNG_KVM_DISPLAY_INFO = 82
*/ */
function CreateDesktopMultiplexor(parent, domain, nodeid, func) { function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
@ -79,6 +80,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
obj.firstData = null; // Index in the image table of the first image in the table, generally this points to the display resolution command. obj.firstData = null; // Index in the image table of the first image in the table, generally this points to the display resolution command.
obj.lastData = null; // Index in the images table of the last image in the table. obj.lastData = null; // Index in the images table of the last image in the table.
obj.lastDisplayInfoData = null; // Pointer to the last display information command from the agent (Number of displays). obj.lastDisplayInfoData = null; // Pointer to the last display information command from the agent (Number of displays).
obj.lastDisplayLocationData = null; // Pointer to the last display location and size command from the agent.
obj.desktopPaused = true; // Current desktop pause state, it's true if all viewers are paused. obj.desktopPaused = true; // Current desktop pause state, it's true if all viewers are paused.
obj.imageCompression = 50; // Current image compression, this is the highest value of all viewers. obj.imageCompression = 50; // Current image compression, this is the highest value of all viewers.
obj.imageScaling = 1024; // Current image scaling, this is the highest value of all viewers. obj.imageScaling = 1024; // Current image scaling, this is the highest value of all viewers.
@ -130,6 +132,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
// If the agent sent display information or console message, send it to the viewer // If the agent sent display information or console message, send it to the viewer
if (obj.lastDisplayInfoData != null) { obj.sendToViewer(peer, obj.lastDisplayInfoData); } if (obj.lastDisplayInfoData != null) { obj.sendToViewer(peer, obj.lastDisplayInfoData); }
if (obj.lastDisplayLocationData != null) { obj.sendToViewer(peer, obj.lastDisplayLocationData); }
if (obj.lastConsoleMessage != null) { obj.sendToViewer(peer, obj.lastConsoleMessage); } if (obj.lastConsoleMessage != null) { obj.sendToViewer(peer, obj.lastConsoleMessage); }
// Log joining the multiplex session // Log joining the multiplex session
@ -524,6 +527,9 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
break; break;
case 14: // Touch setup case 14: // Touch setup
break; break;
case 82: // Request display information
if (obj.lastDisplayLocationData != null) { obj.sendToAgent(obj.lastDisplayLocationData); }
break;
case 85: // Unicode Key Events, forward to agent case 85: // Unicode Key Events, forward to agent
if (viewer.viewOnly == false) { obj.sendToAgent(data); } if (viewer.viewOnly == false) { obj.sendToAgent(data); }
break; break;
@ -678,6 +684,12 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
// Send this to all viewers right away // Send this to all viewers right away
obj.sendToAllViewers(data); obj.sendToAllViewers(data);
break; break;
case 82:
// Display information
if ((data.length < 14) || (((data.length - 4) % 10) != 0)) break; // Command must be 14 bytes and have header + 10 byte for each display.
obj.lastDisplayLocationData = data;
obj.sendToAllViewers(data);
break;
case 87: // MNG_KVM_INPUT_LOCK case 87: // MNG_KVM_INPUT_LOCK
// Send this to all viewers right away // Send this to all viewers right away
// This will update all views on the current state of the input lock // This will update all views on the current state of the input lock

View File

@ -271,6 +271,12 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
console.log('KVM: ' + str.substring(1)); console.log('KVM: ' + str.substring(1));
} }
break; break;
case 82: // DISPLAY LOCATION & SIZE
if ((cmdsize < 4) || (((cmdsize - 4) % 10) != 0)) break;
var screenCount = ((cmdsize - 4) / 10), screenInfo = {}, ptr = 4;
for (var i = 0; i < screenCount; i++) { screenInfo[(view[ptr + 0] << 8) + view[ptr + 1]] = { x: ((view[ptr + 2] << 8) + view[ptr + 3]), y: ((view[ptr + 4] << 8) + view[ptr + 5]), w: ((view[ptr + 6] << 8) + view[ptr + 7]), h: ((view[ptr + 8] << 8) + view[ptr + 9]) }; ptr += 10; }
console.log('ScreenInfo', JSON.stringify(screenInfo, null, 2));
break;
case 87: // MNG_KVM_INPUT_LOCK case 87: // MNG_KVM_INPUT_LOCK
if (cmdsize != 5) break; if (cmdsize != 5) break;
if ((obj.RemoteInputLock == null) || (obj.RemoteInputLock !== (view[4] != 0))) { if ((obj.RemoteInputLock == null) || (obj.RemoteInputLock !== (view[4] != 0))) {