mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
Initial connect instruction support, connection UUIDs
This commit is contained in:
@@ -111,6 +111,12 @@ public class GuacamoleSession {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
synchronized (session) {
|
||||
return client != null;
|
||||
}
|
||||
}
|
||||
|
||||
public GuacamoleConfiguration getConfiguration() {
|
||||
return config;
|
||||
}
|
||||
@@ -126,8 +132,12 @@ public class GuacamoleSession {
|
||||
}
|
||||
|
||||
public void disconnect() throws GuacamoleException {
|
||||
if (client != null)
|
||||
if (client != null) {
|
||||
client.disconnect();
|
||||
|
||||
session.removeAttribute("CLIENT");
|
||||
client = null;
|
||||
}
|
||||
}
|
||||
|
||||
public ReentrantLock getInstructionStreamLock() {
|
||||
|
@@ -30,10 +30,16 @@ import net.sourceforge.guacamole.net.XMLGuacamoleServlet;
|
||||
|
||||
public class Inbound extends XMLGuacamoleServlet {
|
||||
|
||||
protected boolean shouldCreateSession() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleRequest(GuacamoleSession session, ServletRequest request, Element root) throws GuacamoleException {
|
||||
|
||||
if (!session.isConnected())
|
||||
session.connect();
|
||||
|
||||
// Send data
|
||||
try {
|
||||
|
||||
|
@@ -32,9 +32,16 @@ import net.sourceforge.guacamole.net.GuacamoleSession;
|
||||
|
||||
public class InstructionStream extends GuacamoleServlet {
|
||||
|
||||
protected boolean shouldCreateSession() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleRequest(GuacamoleSession session, HttpServletRequest request, HttpServletResponse response) throws GuacamoleException {
|
||||
|
||||
if (!session.isConnected())
|
||||
session.connect();
|
||||
|
||||
ReentrantLock instructionStreamLock = session.getInstructionStreamLock();
|
||||
instructionStreamLock.lock();
|
||||
|
||||
|
@@ -115,6 +115,10 @@ function VNCClient(display) {
|
||||
this.enableKeyboard();
|
||||
|
||||
function sendKeyEvent(pressed, keysym) {
|
||||
// Do not send requests if not connected
|
||||
if (!isConnected())
|
||||
return;
|
||||
|
||||
sendMessage("key:" + keysym + "," + pressed + ";");
|
||||
}
|
||||
|
||||
@@ -159,6 +163,10 @@ function VNCClient(display) {
|
||||
|
||||
function sendMouseState(mouseState) {
|
||||
|
||||
// Do not send requests if not connected
|
||||
if (!isConnected())
|
||||
return;
|
||||
|
||||
// Build mask
|
||||
var buttonMask = 0;
|
||||
if (mouseState.getLeft()) buttonMask |= 1;
|
||||
@@ -176,10 +184,6 @@ function VNCClient(display) {
|
||||
|
||||
function sendMessage(message) {
|
||||
|
||||
// Do not send requests if not connected
|
||||
if (!isConnected())
|
||||
return;
|
||||
|
||||
// Add event to queue, restart send loop if finished.
|
||||
outputMessageBuffer += message;
|
||||
if (sendingMessages == 0)
|
||||
@@ -189,10 +193,6 @@ function VNCClient(display) {
|
||||
|
||||
function sendPendingMessages() {
|
||||
|
||||
// Do not send requests if not connected
|
||||
if (!isConnected())
|
||||
return;
|
||||
|
||||
if (outputMessageBuffer.length > 0) {
|
||||
|
||||
sendingMessages = 1;
|
||||
@@ -560,20 +560,11 @@ function VNCClient(display) {
|
||||
this.connect = function() {
|
||||
|
||||
// Attempt connection
|
||||
var connect_xmlhttprequest = new XMLHttpRequest();
|
||||
connect_xmlhttprequest.open("GET", "connect", false);
|
||||
|
||||
setState(STATE_CONNECTING);
|
||||
connect_xmlhttprequest.send(null);
|
||||
sendMessage("connect;"); // Start new guacamole session
|
||||
|
||||
// Handle result (and check for errors)
|
||||
var message = new GuacamoleMessage(connect_xmlhttprequest.responseXML);
|
||||
if (!message.hasErrors()) {
|
||||
setState(STATE_WAITING);
|
||||
handleResponse(makeRequest());
|
||||
}
|
||||
else
|
||||
handleErrors(message);
|
||||
setState(STATE_WAITING);
|
||||
handleResponse(makeRequest());
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user