diff --git a/guacamole/client/src/net/sourceforge/guacamole/GuacamoleClient.java b/guacamole/client/src/net/sourceforge/guacamole/GuacamoleClient.java index c79c5fe20..b94d8eee3 100644 --- a/guacamole/client/src/net/sourceforge/guacamole/GuacamoleClient.java +++ b/guacamole/client/src/net/sourceforge/guacamole/GuacamoleClient.java @@ -33,6 +33,8 @@ import java.io.OutputStreamWriter; import net.sourceforge.guacamole.instruction.Instruction; import net.sourceforge.guacamole.GuacamoleException; +import net.sourceforge.guacamole.event.EventQueue; +import net.sourceforge.guacamole.event.EventHandler; import net.sourceforge.guacamole.event.KeyEvent; import net.sourceforge.guacamole.event.PointerEvent; @@ -55,24 +57,24 @@ public class GuacamoleClient extends Client { } - public void send(KeyEvent event) throws GuacamoleException { - try { + private static final int EVENT_DEADLINE = 500; + + private EventQueue keyEvents = new EventQueue(new EventHandler() { + + public void handle(KeyEvent event) throws IOException { int pressed = 0; if (event.getPressed()) pressed = 1; output.write("key:" + event.getKeySym() + "," + pressed + ";"); output.flush(); } - catch (IOException e) { - throw new GuacamoleException(e); - } - } + }, EVENT_DEADLINE); - public void send(PointerEvent event) throws GuacamoleException { + private EventQueue pointerEvents = new EventQueue(new EventHandler() { - try { + public void handle(PointerEvent event) throws IOException { int mask = 0; if (event.isLeftButtonPressed()) mask |= 1; if (event.isMiddleButtonPressed()) mask |= 2; @@ -84,6 +86,26 @@ public class GuacamoleClient extends Client { output.write("mouse:" + event.getX() + "," + event.getY() + "," + mask + ";"); output.flush(); } + + }, EVENT_DEADLINE); + + + public void send(KeyEvent event) throws GuacamoleException { + + try { + keyEvents.add(event); + } + catch (IOException e) { + throw new GuacamoleException(e); + } + + } + + public void send(PointerEvent event) throws GuacamoleException { + + try { + pointerEvents.add(event); + } catch (IOException e) { throw new GuacamoleException(e); }