Hello:

I'm writing a Gauacamole app using the tutorial from the Guacamole web site: https://guacamole.incubator.apache.org/doc/gug/writing-you-own-guacamole-app.html

When I g to create a configuration for a new tunnel (Java code), I want to be able to pass in the configuration information from the web client (javascript) instead of hard-coding it. How can I get that information? See Java code and javascript web client code below.

Any help would be much appreciated. On a side note, can this be done in pure client-side javascript without the server-side java?



Server-side:

publicclassTutorialGuacamoleTunnelServlet
extendsGuacamoleHTTPTunnelServlet{
@Override
protectedGuacamoleTunneldoConnect(HttpServletRequestrequest)
throwsGuacamoleException{
// Create our configuration
GuacamoleConfigurationconfig=newGuacamoleConfiguration();
config.setProtocol("rdp");
config.setParameter("hostname", "192.168.0.186");
config.setParameter("port", "3389");
config.setParameter("username", "rdpuser");
config.setParameter("password", "****");
config.setParameter("ignore-cert", "true");
config.setParameter("width", "1440");
config.setParameter("height", "800");
// Connect to guacd - everything is hard-coded here.
GuacamoleSocketsocket=newConfiguredGuacamoleSocket(
newInetGuacamoleSocket("localhost", 4822),
config
);
// Return a new tunnel which uses the connected socket
returnnewSimpleGuacamoleTunnel(socket);
}
}
Javascript client:
<!-- Init -->
<scripttype="text/javascript">/* <![CDATA[ */
sc_width= window.screen.availWidth;
sc_height= window.screen.availHeight;
// Get display div from document
vardisplay= document.getElementById("screen");
// Instantiate client, using an HTTP tunnel for communications.
varguac= newGuacamole.Client(
newGuacamole.HTTPTunnel("tunnel")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror= function(error) {
alert(error);
};
// Connect
guac.connect();
// Disconnect on close
window.onunload= function() {
guac.disconnect();
}

Reply via email to