feat: vendor guacamole-common-js and console wrapper
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// Thin wrapper over the vendored guacamole-common-js client.
|
||||
// The library attaches a global `Guacamole` object when loaded.
|
||||
declare const Guacamole: any;
|
||||
|
||||
export function openConsole(container: HTMLElement, wsUrl: string): { disconnect: () => void } {
|
||||
const tunnel = new Guacamole.WebSocketTunnel(wsUrl);
|
||||
const client = new Guacamole.Client(tunnel);
|
||||
|
||||
container.innerHTML = "";
|
||||
container.appendChild(client.getDisplay().getElement());
|
||||
|
||||
client.connect("");
|
||||
|
||||
// Wire keyboard + mouse.
|
||||
const mouse = new Guacamole.Mouse(client.getDisplay().getElement());
|
||||
mouse.onmousedown = mouse.onmouseup = mouse.onmousemove = (state: any) =>
|
||||
client.sendMouseState(state);
|
||||
const keyboard = new Guacamole.Keyboard(document);
|
||||
keyboard.onkeydown = (k: number) => client.sendKeyEvent(1, k);
|
||||
keyboard.onkeyup = (k: number) => client.sendKeyEvent(0, k);
|
||||
|
||||
return {
|
||||
disconnect() {
|
||||
client.disconnect();
|
||||
},
|
||||
};
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user