We want to save the user's keyboard movements using guacamole-common-js to receive the commands of the user as a string, not as a keylogger(keysym).For instance, when the user writes ls -l command, guacamole writes on console 108,115,32,45,108(https://www.tcl.tk/man/tcl8.4/TkCmd/keysyms.html). However, we want to get ls -l line, as the user press enter key on the client-side. Moreover, as we search guacamole-common-js, we found functions such as OutputStream, StringWriter, StringWriter, etc. Unfortunately, we didn't find any documentation about these functions which are in all.min.js
Thank you in advance!
<script type="text/javascript">
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
new Guacamole.WebSocketTunnel("ws://localhost:8080")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function (error) {
console.log(error);
};
// Connect
guac.connect("token=v81l2bdBf6Qpbejs21AWUvuUb9vqMBO4yGNGN-olCFmGbioQmEVfSVJTCQrBArX-Qyp2kbsv7GkefpBGeGq-YQX4QQ0ofYJonmmQ5WyR9JmxulBnEwBDSgHkyVCW-2tP");
// Disconnect on close
window.onunload = function () {
guac.disconnect();
}
// Mouse
var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
mouse.onEach(['mousedown', 'mouseup', 'mousemove'], function sendMouseEvent(e) {
guac.sendMouseState(e.state);
});
// Keyboard
var keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = function (keysym) {
guac.sendKeyEvent(1, keysym);
};
keyboard.onkeyup = function (keysym) {
guac.sendKeyEvent(0, keysym);
};
var xxx=Guacamole.InputStream(guac);
console.log('text---' + xxx);
//function foo(stream , mimetype) {
// if (/^text\//.exec(mimetype)) {
// var stringReader = new Guacamole.StringReader(stream);
// console.log('stringReader---'+stringReader);
// var json = "";
// stringReader.ontext = function ontext(text) {
// json += text
// console.log('text---' + text);
// }
// stringReader.onend = function () {
// guac_client.clipboardData = '';
// guac_client.clipboardData = json;
// }
// }
//}
//array_reader.ondata = function (buffer) {
// // Decode UTF-8
// var text = utf8Parser.decode(buffer);
// // Call handler, if present
// if (guac_reader.ontext)
// guac_reader.ontext(text);
//};
//// Simply call onend when end received
//array_reader.onend = function () {
// if (guac_reader.onend)
// guac_reader.onend();
//};
/* ]]> */</script>