How to use the guacamole-common-js.HTTPTunnel function in guacamole-common-js

To help you get started, we’ve selected a few guacamole-common-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / incubator-dlab / services / self-service / src / main / resources / webapp / src / app / webterminal / webterminal.component.ts View on Github external
public open(id_parameter: string, endpoint_parameter: string) {
    // added to simplify development process
    const url = environment.production ? window.location.origin : API_URL;
    const tunnel = new Guacamole.HTTPTunnel(
      `${url}/api/tunnel`, false,
      { 'Authorization': `Bearer ${this.storageService.getToken()}` }
    );

    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();