mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	Added GuacamoleReader.available(), using to determine appropriate times to flush tunnel servlet output.
This commit is contained in:
		| @@ -48,6 +48,19 @@ import net.sourceforge.guacamole.protocol.GuacamoleInstruction; | ||||
|  */ | ||||
| public interface GuacamoleReader { | ||||
|  | ||||
|     /** | ||||
|      * Returns whether instruction data is available for reading. Note that | ||||
|      * this does not guarantee an entire instruction is available. If a full | ||||
|      * instruction is not available, this function can return true, and a call | ||||
|      * to read() will still block. | ||||
|      *  | ||||
|      * @return true if instruction data is available for reading, false | ||||
|      *         otherwise. | ||||
|      * @throws GuacamoleException If an error occurs while checking for | ||||
|      *                            available data. | ||||
|      */ | ||||
|     public boolean available() throws GuacamoleException; | ||||
|      | ||||
|     /** | ||||
|      * Reads at least one complete Guacamole instruction, returning a buffer | ||||
|      * containing one or more complete Guacamole instructions and no | ||||
|   | ||||
| @@ -70,6 +70,16 @@ public class ReaderGuacamoleReader implements GuacamoleReader { | ||||
|     private char[] buffer = new char[20480]; | ||||
|     private int usedLength = 0; | ||||
|  | ||||
|     @Override | ||||
|     public boolean available() throws GuacamoleException { | ||||
|         try { | ||||
|             return input.ready() || usedLength != 0; | ||||
|         } | ||||
|         catch (IOException e) { | ||||
|             throw new GuacamoleException(e); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public char[] read() throws GuacamoleException { | ||||
|  | ||||
|   | ||||
| @@ -224,8 +224,12 @@ public abstract class GuacamoleTunnelServlet extends HttpServlet { | ||||
|  | ||||
|                 // Get message output bytes | ||||
|                 out.write(message, 0, message.length); | ||||
|                 out.flush(); | ||||
|                 response.flushBuffer(); | ||||
|  | ||||
|                 // Flush if we expect to wait | ||||
|                 if (!reader.available()) { | ||||
|                     out.flush(); | ||||
|                     response.flushBuffer(); | ||||
|                 } | ||||
|  | ||||
|                 // No more messages another stream can take over | ||||
|                 if (tunnel.hasQueuedReaderThreads()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user