You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2016/03/20 03:15:32 UTC
[22/50] incubator-guacamole-manual git commit: GUAC-1435: Go through
webapp tutorial. Verify correctness. Add resulting source.
GUAC-1435: Go through webapp tutorial. Verify correctness. Add resulting source.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/commit/92f04899
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/tree/92f04899
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/diff/92f04899
Branch: refs/heads/master
Commit: 92f048992a7cf814bac7e2ed5c9828947946219c
Parents: 97af0b6
Author: Michael Jumper <mi...@guac-dev.org>
Authored: Tue Dec 15 15:11:47 2015 -0800
Committer: Michael Jumper <mi...@guac-dev.org>
Committed: Tue Dec 15 15:11:47 2015 -0800
----------------------------------------------------------------------
tutorials/guacamole-tutorial/.gitignore | 3 +
tutorials/guacamole-tutorial/pom.xml | 79 ++++++++++++++++++++
.../example/TutorialGuacamoleTunnelServlet.java | 38 ++++++++++
.../src/main/webapp/WEB-INF/web.xml | 28 +++++++
.../src/main/webapp/index.html | 68 +++++++++++++++++
5 files changed, 216 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/blob/92f04899/tutorials/guacamole-tutorial/.gitignore
----------------------------------------------------------------------
diff --git a/tutorials/guacamole-tutorial/.gitignore b/tutorials/guacamole-tutorial/.gitignore
new file mode 100644
index 0000000..c3a023f
--- /dev/null
+++ b/tutorials/guacamole-tutorial/.gitignore
@@ -0,0 +1,3 @@
+*~
+target/
+META-INF/
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/blob/92f04899/tutorials/guacamole-tutorial/pom.xml
----------------------------------------------------------------------
diff --git a/tutorials/guacamole-tutorial/pom.xml b/tutorials/guacamole-tutorial/pom.xml
new file mode 100644
index 0000000..a394b23
--- /dev/null
+++ b/tutorials/guacamole-tutorial/pom.xml
@@ -0,0 +1,79 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.glyptodon.guacamole</groupId>
+ <artifactId>guacamole-tutorial</artifactId>
+ <packaging>war</packaging>
+ <version>0.9.9</version>
+ <name>guacamole-tutorial</name>
+ <url>http://guac-dev.org/</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <!-- Compile using Java 1.6 -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <!-- Overlay guacamole-common-js (zip) -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <overlays>
+ <overlay>
+ <groupId>org.glyptodon.guacamole</groupId>
+ <artifactId>guacamole-common-js</artifactId>
+ <type>zip</type>
+ </overlay>
+ </overlays>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+ <dependencies>
+
+ <!-- Servlet API -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Main Guacamole library -->
+ <dependency>
+ <groupId>org.glyptodon.guacamole</groupId>
+ <artifactId>guacamole-common</artifactId>
+ <version>0.9.9</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- Guacamole JavaScript library -->
+ <dependency>
+ <groupId>org.glyptodon.guacamole</groupId>
+ <artifactId>guacamole-common-js</artifactId>
+ <version>0.9.9</version>
+ <type>zip</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/blob/92f04899/tutorials/guacamole-tutorial/src/main/java/org/glyptodon/guacamole/net/example/TutorialGuacamoleTunnelServlet.java
----------------------------------------------------------------------
diff --git a/tutorials/guacamole-tutorial/src/main/java/org/glyptodon/guacamole/net/example/TutorialGuacamoleTunnelServlet.java b/tutorials/guacamole-tutorial/src/main/java/org/glyptodon/guacamole/net/example/TutorialGuacamoleTunnelServlet.java
new file mode 100644
index 0000000..1a2e958
--- /dev/null
+++ b/tutorials/guacamole-tutorial/src/main/java/org/glyptodon/guacamole/net/example/TutorialGuacamoleTunnelServlet.java
@@ -0,0 +1,38 @@
+package org.glyptodon.guacamole.net.example;
+
+import javax.servlet.http.HttpServletRequest;
+import org.glyptodon.guacamole.GuacamoleException;
+import org.glyptodon.guacamole.net.GuacamoleSocket;
+import org.glyptodon.guacamole.net.GuacamoleTunnel;
+import org.glyptodon.guacamole.net.InetGuacamoleSocket;
+import org.glyptodon.guacamole.net.SimpleGuacamoleTunnel;
+import org.glyptodon.guacamole.protocol.ConfiguredGuacamoleSocket;
+import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
+import org.glyptodon.guacamole.servlet.GuacamoleHTTPTunnelServlet;
+
+public class TutorialGuacamoleTunnelServlet
+ extends GuacamoleHTTPTunnelServlet {
+
+ @Override
+ protected GuacamoleTunnel doConnect(HttpServletRequest request)
+ throws GuacamoleException {
+
+ // Create our configuration
+ GuacamoleConfiguration config = new GuacamoleConfiguration();
+ config.setProtocol("vnc");
+ config.setParameter("hostname", "localhost");
+ config.setParameter("port", "5901");
+ config.setParameter("password", "potato");
+
+ // Connect to guacd - everything is hard-coded here.
+ GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
+ new InetGuacamoleSocket("localhost", 4822),
+ config
+ );
+
+ // Return a new tunnel which uses the connected socket
+ return new SimpleGuacamoleTunnel(socket);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/blob/92f04899/tutorials/guacamole-tutorial/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/tutorials/guacamole-tutorial/src/main/webapp/WEB-INF/web.xml b/tutorials/guacamole-tutorial/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..064e95e
--- /dev/null
+++ b/tutorials/guacamole-tutorial/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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>
+
+ <!-- Guacamole Tunnel Servlet -->
+ <servlet>
+ <description>Tunnel servlet.</description>
+ <servlet-name>Tunnel</servlet-name>
+ <servlet-class>
+ org.glyptodon.guacamole.net.example.TutorialGuacamoleTunnelServlet
+ </servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Tunnel</servlet-name>
+ <url-pattern>/tunnel</url-pattern>
+ </servlet-mapping>
+
+</web-app>
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-manual/blob/92f04899/tutorials/guacamole-tutorial/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/tutorials/guacamole-tutorial/src/main/webapp/index.html b/tutorials/guacamole-tutorial/src/main/webapp/index.html
new file mode 100644
index 0000000..15018a2
--- /dev/null
+++ b/tutorials/guacamole-tutorial/src/main/webapp/index.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+
+ <head>
+ <title>Guacamole Tutorial</title>
+ </head>
+
+ <body>
+
+ <!-- Guacamole -->
+ <script type="text/javascript"
+ src="guacamole-common-js/all.min.js"></script>
+
+ <!-- Display -->
+ <div id="display"></div>
+
+ <!-- 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().getElement());
+
+ // 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().getElement());
+
+ 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>