Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
guacRef.current.onstatechange = (newState) => {
setClientState(newState);
};
// Setup connection parameters, like resolution and supported audio types
let connectionParams = {
audio: []
};
// if current instance is allowed to control remote display size - include window size in connection info
if (controlSize) {
connectionParams.width = displayRef.current.clientWidth;
connectionParams.height = displayRef.current.clientHeight;
}
let supportedAudioTypes = Guacamole.AudioPlayer.getSupportedTypes();
if (supportedAudioTypes.length > 0) {
connectionParams.audio = supportedAudioTypes.map(item => item + ";rate=44100,channels=2")
}
// Set connection parameters as we will use them later to reconnect
connectParamsRef.current = connectionParams;
// Everything has been setup - we can initiate connection
guacRef.current.connect(getConnectionString());
// Specify how to clean up after this effect:
return function cleanup() {
// Disconnect Guacamole Client, so server know'w we don't need any updates and teminates connection
// to server
guacRef.current.disconnect();
};