How to use the guacamole-common-js.WebSocketTunnel 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 paidem / guacozy / frontend / src / Components / GuacViewer / GuacViewer.js View on Github external
useEffect(() => {
        // Determine websocket URI
        const protocolPrefix = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
        let {host} = window.location;
        let webSocketFullUrl = `${protocolPrefix}//${host}${wspath}`;

        guacRef.current = new Guacamole.Client(new Guacamole.WebSocketTunnel(webSocketFullUrl));

        displayRef.current.appendChild(guacRef.current.getDisplay().getElement());

        // Error handler
        guacRef.current.onerror = function (error) {
            let msg = error.message;

            if (GUACAMOLE_STATUS[error.code]) {
                msg = <p>
                    {error.message}<br>
                    {GUACAMOLE_STATUS[error.code].name}<br>
                    {GUACAMOLE_STATUS[error.code].text}
                </p>
            }

            setErrorMessage(msg);