Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);