mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Add guacamole-example, modified to work with 0.8.*
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
|
||||
package net.sourceforge.guacamole.net.example;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import net.sourceforge.guacamole.GuacamoleException;
|
||||
import net.sourceforge.guacamole.net.GuacamoleSocket;
|
||||
import net.sourceforge.guacamole.net.GuacamoleTunnel;
|
||||
import net.sourceforge.guacamole.net.InetGuacamoleSocket;
|
||||
import net.sourceforge.guacamole.protocol.ConfiguredGuacamoleSocket;
|
||||
import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
|
||||
import net.sourceforge.guacamole.servlet.GuacamoleHTTPTunnelServlet;
|
||||
import net.sourceforge.guacamole.servlet.GuacamoleSession;
|
||||
|
||||
/*
|
||||
* Guacamole - Clientless Remote Desktop
|
||||
* Copyright (C) 2010 Michael Jumper
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
public class DummyGuacamoleTunnelServlet extends GuacamoleHTTPTunnelServlet {
|
||||
|
||||
@Override
|
||||
protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException {
|
||||
|
||||
HttpSession httpSession = request.getSession(true);
|
||||
|
||||
// guacd connection information
|
||||
String hostname = "localhost";
|
||||
int port = 4822;
|
||||
|
||||
// VNC connection information
|
||||
GuacamoleConfiguration config = new GuacamoleConfiguration();
|
||||
config.setProtocol("vnc");
|
||||
config.setParameter("hostname", "localhost");
|
||||
config.setParameter("port", "5901");
|
||||
config.setParameter("password", "potato");
|
||||
|
||||
// Connect to guacd, proxying a connection to the VNC server above
|
||||
GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
|
||||
new InetGuacamoleSocket(hostname, port),
|
||||
config
|
||||
);
|
||||
|
||||
// Create tunnel from now-configured socket
|
||||
GuacamoleTunnel tunnel = new GuacamoleTunnel(socket);
|
||||
|
||||
// Attach tunnel
|
||||
GuacamoleSession session = new GuacamoleSession(httpSession);
|
||||
session.attachTunnel(tunnel);
|
||||
|
||||
return tunnel;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Context antiJARLocking="true" path=""/>
|
43
doc/guacamole-example/src/main/webapp/WEB-INF/web.xml
Normal file
43
doc/guacamole-example/src/main/webapp/WEB-INF/web.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Guacamole - Clientless Remote Desktop
|
||||
Copyright (C) 2010 Michael Jumper
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
|
||||
|
||||
<!-- Basic config -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
|
||||
<!-- Guacamole Tunnel Servlet -->
|
||||
<servlet>
|
||||
<description>Tunnel servlet.</description>
|
||||
<servlet-name>Tunnel</servlet-name>
|
||||
<servlet-class>net.sourceforge.guacamole.net.example.DummyGuacamoleTunnelServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>Tunnel</servlet-name>
|
||||
<url-pattern>/tunnel</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
</web-app>
|
BIN
doc/guacamole-example/src/main/webapp/dot.gif
Normal file
BIN
doc/guacamole-example/src/main/webapp/dot.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 B |
23
doc/guacamole-example/src/main/webapp/guacamole.css
Normal file
23
doc/guacamole-example/src/main/webapp/guacamole.css
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
/*
|
||||
* Guacamole - Clientless Remote Desktop
|
||||
* Copyright (C) 2010 Michael Jumper
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
.guac-hide-cursor {
|
||||
cursor: url('dot.gif'),default;
|
||||
}
|
||||
|
98
doc/guacamole-example/src/main/webapp/index.html
Normal file
98
doc/guacamole-example/src/main/webapp/index.html
Normal file
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE HTML>
|
||||
|
||||
<!--
|
||||
Guacamole - Clientless Remote Desktop
|
||||
Copyright (C) 2010 Michael Jumper
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="guacamole.css"/>
|
||||
<title>Guacamole (EXAMPLE)</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- Display -->
|
||||
<div id="display"></div>
|
||||
|
||||
<!-- Input abstractions -->
|
||||
<script type="text/javascript"
|
||||
src="guacamole-common-js/keyboard.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="guacamole-common-js/mouse.js"></script>
|
||||
|
||||
<!-- Client core scripts -->
|
||||
<script type="text/javascript"
|
||||
src="guacamole-common-js/layer.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="guacamole-common-js/tunnel.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="guacamole-common-js/guacamole.js"></script>
|
||||
|
||||
<!-- Init -->
|
||||
<script type="text/javascript"> /* <![CDATA[ */
|
||||
|
||||
// Get display div from document
|
||||
var display = document.getElementById("display");
|
||||
|
||||
// Instantiate client, using an HTTP tunnel for communications.
|
||||
var guac = new Guacamole.Client(
|
||||
new Guacamole.HTTPTunnel("tunnel")
|
||||
);
|
||||
|
||||
// Add client to display div
|
||||
display.appendChild(guac.getDisplay());
|
||||
|
||||
// Error handler
|
||||
guac.onerror = function(error) {
|
||||
alert(error);
|
||||
};
|
||||
|
||||
// Connect
|
||||
guac.connect();
|
||||
|
||||
// Disconnect on close
|
||||
window.onunload = function() {
|
||||
guac.disconnect();
|
||||
}
|
||||
|
||||
// Mouse
|
||||
var mouse = new Guacamole.Mouse(guac.getDisplay());
|
||||
|
||||
mouse.onmousedown =
|
||||
mouse.onmouseup =
|
||||
mouse.onmousemove = function(mouseState) {
|
||||
guac.sendMouseState(mouseState);
|
||||
};
|
||||
|
||||
// Keyboard
|
||||
var keyboard = new Guacamole.Keyboard(document);
|
||||
|
||||
keyboard.onkeydown = function (keysym) {
|
||||
guac.sendKeyEvent(1, keysym);
|
||||
};
|
||||
|
||||
keyboard.onkeyup = function (keysym) {
|
||||
guac.sendKeyEvent(0, keysym);
|
||||
};
|
||||
|
||||
/* ]]> */ </script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user