diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/Client.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/Client.java
deleted file mode 100644
index 076f0c371..000000000
--- a/guacamole-common/src/main/java/net/sourceforge/guacamole/Client.java
+++ /dev/null
@@ -1,28 +0,0 @@
-
-package net.sourceforge.guacamole;
-
-/*
- * 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 .
- */
-
-public abstract class Client {
-
- public abstract void write(char[] chunk, int off, int len) throws GuacamoleException;
- public abstract char[] read() throws GuacamoleException;
- public abstract void disconnect() throws GuacamoleException;
-
-}
diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/GuacamoleClient.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/GuacamoleClient.java
index 1dc4f69f2..80f0c1bf5 100644
--- a/guacamole-common/src/main/java/net/sourceforge/guacamole/GuacamoleClient.java
+++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/GuacamoleClient.java
@@ -1,6 +1,8 @@
package net.sourceforge.guacamole;
+import net.sourceforge.guacamole.net.Configuration;
+
/*
* Guacamole - Clientless Remote Desktop
* Copyright (C) 2010 Michael Jumper
@@ -19,107 +21,17 @@ package net.sourceforge.guacamole;
* along with this program. If not, see .
*/
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
+public abstract class GuacamoleClient {
-import java.io.Reader;
-import java.io.InputStreamReader;
+ public abstract void write(char[] chunk, int off, int len) throws GuacamoleException;
+ public abstract char[] read() throws GuacamoleException;
+ public abstract void disconnect() throws GuacamoleException;
-import java.io.Writer;
-import java.io.OutputStreamWriter;
+ public void connect(Configuration config) throws GuacamoleException {
-
-public class GuacamoleClient extends Client {
-
- private Socket sock;
- private Reader input;
- private Writer output;
-
- public GuacamoleClient(String hostname, int port) throws GuacamoleException {
-
- try {
- sock = new Socket(InetAddress.getByName(hostname), port);
- input = new InputStreamReader(sock.getInputStream());
- output = new OutputStreamWriter(sock.getOutputStream());
- }
- catch (IOException e) {
- throw new GuacamoleException(e);
- }
-
- }
-
- public void write(char[] chunk, int off, int len) throws GuacamoleException {
- try {
- output.write(chunk, off, len);
- output.flush();
- }
- catch (IOException e) {
- throw new GuacamoleException(e);
- }
- }
-
- public void disconnect() throws GuacamoleException {
- try {
- sock.close();
- }
- catch (IOException e) {
- throw new GuacamoleException(e);
- }
- }
-
- private int usedLength = 0;
- private char[] buffer = new char[20000];
-
- public char[] read() throws GuacamoleException {
-
- try {
-
- // While we're blocking, or input is available
- for (;;) {
-
- // If past threshold, resize buffer before reading
- if (usedLength > buffer.length/2) {
- char[] biggerBuffer = new char[buffer.length*2];
- System.arraycopy(buffer, 0, biggerBuffer, 0, usedLength);
- buffer = biggerBuffer;
- }
-
- // Attempt to fill buffer
- int numRead = input.read(buffer, usedLength, buffer.length - usedLength);
- if (numRead == -1)
- return null;
-
- int prevLength = usedLength;
- usedLength += numRead;
-
- for (int i=usedLength-1; i>=prevLength; i--) {
-
- char readChar = buffer[i];
-
- // If end of instruction, return it.
- if (readChar == ';') {
-
- // Get instruction
- char[] chunk = new char[i+1];
- System.arraycopy(buffer, 0, chunk, 0, i+1);
-
- // Reset buffer
- usedLength -= i+1;
- System.arraycopy(buffer, i+1, buffer, 0, usedLength);
-
- // Return instruction string
- return chunk;
- }
-
- }
-
- } // End read loop
-
- }
- catch (IOException e) {
- throw new GuacamoleException(e);
- }
+ // TODO: Send "select" and "connect" messages in client connect function (based on config) ... to be implemented.
+ char[] initMessages = "select:vnc;connect:localhost,5901,potato;".toCharArray();
+ write(initMessages, 0, initMessages.length);
}
diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/GuacamoleTCPClient.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/GuacamoleTCPClient.java
new file mode 100644
index 000000000..f0c0b23c1
--- /dev/null
+++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/GuacamoleTCPClient.java
@@ -0,0 +1,126 @@
+
+package net.sourceforge.guacamole;
+
+/*
+ * 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 .
+ */
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+
+import java.io.Reader;
+import java.io.InputStreamReader;
+
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+
+
+public class GuacamoleTCPClient extends GuacamoleClient {
+
+ private Socket sock;
+ private Reader input;
+ private Writer output;
+
+ public GuacamoleTCPClient(String hostname, int port) throws GuacamoleException {
+
+ try {
+ sock = new Socket(InetAddress.getByName(hostname), port);
+ input = new InputStreamReader(sock.getInputStream());
+ output = new OutputStreamWriter(sock.getOutputStream());
+ }
+ catch (IOException e) {
+ throw new GuacamoleException(e);
+ }
+
+ }
+
+ public void write(char[] chunk, int off, int len) throws GuacamoleException {
+ try {
+ output.write(chunk, off, len);
+ output.flush();
+ }
+ catch (IOException e) {
+ throw new GuacamoleException(e);
+ }
+ }
+
+ public void disconnect() throws GuacamoleException {
+ try {
+ sock.close();
+ }
+ catch (IOException e) {
+ throw new GuacamoleException(e);
+ }
+ }
+
+ private int usedLength = 0;
+ private char[] buffer = new char[20000];
+
+ public char[] read() throws GuacamoleException {
+
+ try {
+
+ // While we're blocking, or input is available
+ for (;;) {
+
+ // If past threshold, resize buffer before reading
+ if (usedLength > buffer.length/2) {
+ char[] biggerBuffer = new char[buffer.length*2];
+ System.arraycopy(buffer, 0, biggerBuffer, 0, usedLength);
+ buffer = biggerBuffer;
+ }
+
+ // Attempt to fill buffer
+ int numRead = input.read(buffer, usedLength, buffer.length - usedLength);
+ if (numRead == -1)
+ return null;
+
+ int prevLength = usedLength;
+ usedLength += numRead;
+
+ for (int i=usedLength-1; i>=prevLength; i--) {
+
+ char readChar = buffer[i];
+
+ // If end of instruction, return it.
+ if (readChar == ';') {
+
+ // Get instruction
+ char[] chunk = new char[i+1];
+ System.arraycopy(buffer, 0, chunk, 0, i+1);
+
+ // Reset buffer
+ usedLength -= i+1;
+ System.arraycopy(buffer, i+1, buffer, 0, usedLength);
+
+ // Return instruction string
+ return chunk;
+ }
+
+ }
+
+ } // End read loop
+
+ }
+ catch (IOException e) {
+ throw new GuacamoleException(e);
+ }
+
+ }
+
+}
diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/GuacamoleProperties.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/GuacamoleProperties.java
index f68c2e4a6..97dff3552 100644
--- a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/GuacamoleProperties.java
+++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/GuacamoleProperties.java
@@ -49,14 +49,6 @@ public class GuacamoleProperties {
}
- public static String getProxyHostname() throws GuacamoleException {
- return GuacamoleProperties.getProperty("guacd-hostname");
- }
-
- public static int getProxyPort() throws GuacamoleException {
- return GuacamoleProperties.getIntProperty("guacd-port", null);
- }
-
public static GuacamoleClientProvider getClientProvider() throws GuacamoleException {
// Get client provider instance
diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/GuacamoleSession.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/GuacamoleSession.java
index 10699246e..430a4aae5 100644
--- a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/GuacamoleSession.java
+++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/GuacamoleSession.java
@@ -23,8 +23,8 @@ import java.util.concurrent.locks.ReentrantLock;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
-import net.sourceforge.guacamole.Client;
import net.sourceforge.guacamole.GuacamoleClient;
+import net.sourceforge.guacamole.GuacamoleTCPClient;
import net.sourceforge.guacamole.GuacamoleException;
public class GuacamoleSession {
@@ -33,11 +33,11 @@ public class GuacamoleSession {
private SessionClient client;
private ReentrantLock instructionStreamLock;
- public class SessionClient extends Client implements HttpSessionBindingListener {
+ public class SessionClient extends GuacamoleClient implements HttpSessionBindingListener {
- private Client client;
+ private GuacamoleClient client;
- public SessionClient(Client client) {
+ public SessionClient(GuacamoleClient client) {
this.client = client;
}
@@ -84,7 +84,7 @@ public class GuacamoleSession {
}
- public void attachClient(GuacamoleClient client) throws GuacamoleException {
+ public void attachClient(GuacamoleTCPClient client) throws GuacamoleException {
synchronized (session) {
diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/authentication/GuacamoleClientProvider.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/authentication/GuacamoleClientProvider.java
index a4989dcac..07e029cfa 100644
--- a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/authentication/GuacamoleClientProvider.java
+++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/authentication/GuacamoleClientProvider.java
@@ -2,7 +2,7 @@
package net.sourceforge.guacamole.net.authentication;
import javax.servlet.http.HttpSession;
-import net.sourceforge.guacamole.GuacamoleClient;
+import net.sourceforge.guacamole.GuacamoleTCPClient;
import net.sourceforge.guacamole.GuacamoleException;
/*
@@ -25,6 +25,6 @@ import net.sourceforge.guacamole.GuacamoleException;
public interface GuacamoleClientProvider {
- public GuacamoleClient createClient(HttpSession session) throws GuacamoleException;
+ public GuacamoleTCPClient createClient(HttpSession session) throws GuacamoleException;
}
diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/authentication/NullGuacamoleClientProvider.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/authentication/NullGuacamoleClientProvider.java
index 786939553..d69908f63 100644
--- a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/authentication/NullGuacamoleClientProvider.java
+++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/authentication/NullGuacamoleClientProvider.java
@@ -2,7 +2,7 @@
package net.sourceforge.guacamole.net.authentication;
import javax.servlet.http.HttpSession;
-import net.sourceforge.guacamole.GuacamoleClient;
+import net.sourceforge.guacamole.GuacamoleTCPClient;
import net.sourceforge.guacamole.GuacamoleException;
/*
@@ -25,7 +25,7 @@ import net.sourceforge.guacamole.GuacamoleException;
public class NullGuacamoleClientProvider implements GuacamoleClientProvider {
- public GuacamoleClient createClient(HttpSession session) throws GuacamoleException {
+ public GuacamoleTCPClient createClient(HttpSession session) throws GuacamoleException {
throw new GuacamoleException("Null provider will not create clients.");
}
diff --git a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/tunnel/Outbound.java b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/tunnel/Outbound.java
index 5b09c463e..46ca3e891 100644
--- a/guacamole-common/src/main/java/net/sourceforge/guacamole/net/tunnel/Outbound.java
+++ b/guacamole-common/src/main/java/net/sourceforge/guacamole/net/tunnel/Outbound.java
@@ -27,7 +27,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import net.sourceforge.guacamole.Client;
+import net.sourceforge.guacamole.GuacamoleClient;
import net.sourceforge.guacamole.GuacamoleException;
import net.sourceforge.guacamole.net.GuacamoleSession;
@@ -54,7 +54,7 @@ public class Outbound extends HttpServlet {
try {
// Query new update from server
- Client client = session.getClient();
+ GuacamoleClient client = session.getClient();
// For all messages, until another stream is ready (we send at least one message)
char[] message;