Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
const guac = new Guacamole.Client(tunnel);
const display = document.getElementById('display');
display.appendChild(guac.getDisplay().getElement());
this.layer = guac.getDisplay().getDefaultLayer();
guac.connect(`{"host" : "${id_parameter}", "endpoint" : "${endpoint_parameter}"}`);
// Error handler
guac.onerror = (error) => console.log(error.message);
window.onunload = () => guac.disconnect();
// Mouse
const mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
mouse.onmousemove = (mouseState) => {
if (navigator.userAgent.indexOf('Firefox') === -1) {
mouseState.x = mouseState.x + 125;
mouseState.y = mouseState.y + 65;
}
guac.sendMouseState(mouseState);
}
const keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = (keysym) => guac.sendKeyEvent(1, keysym);
keyboard.onkeyup = (keysym) => guac.sendKeyEvent(0, keysym);
}
}
// somehow Right Ctrl is not sent, so send Left Ctrl instead
if (keysym === 65508) return 65507;
return keysym
};
keyboard.onkeydown = function (keysym) {
guacRef.current.sendKeyEvent(1, fixKeys(keysym));
};
keyboard.onkeyup = function (keysym) {
guacRef.current.sendKeyEvent(0, fixKeys(keysym));
};
// Mouse
let mouse = new Guacamole.Mouse(displayRef.current);
mouse.onmousemove = function (mouseState) {
mouseState.x = mouseState.x / scale.current;
mouseState.y = mouseState.y / scale.current;
guacRef.current.sendMouseState(mouseState);
};
mouse.onmousedown = mouse.onmouseup = function (mouseState) {
guacRef.current.sendMouseState(mouseState);
};
}, [controlInput]);