private void handleAck ( GuacamoleInstruction instruction ) { // Verify all required arguments are present List < String > args = instruction . getArgs ( ) ; if ( args . size ( ) < 3 ) return ; // Pull associated stream String index = args . get ( 0 ) ; InterceptedStream < InputStream > stream = getInterceptedStream ( index ) ; if ( stream == null ) return ; // Pull status code String status = args . get ( 2 ) ; // Terminate stream if an error is encountered if ( ! status . equals ( "0" ) ) { // Parse status code as integer int code ; try { code = Integer . parseInt ( status ) ; } // Assume internal error if parsing fails catch ( NumberFormatException e ) { logger . debug ( "Translating invalid status code \"{}\" to SERVER_ERROR." , status ) ; code = GuacamoleStatus . SERVER_ERROR . getGuacamoleStatusCode ( ) ; } // Flag error and close stream stream . setStreamError ( code , args . get ( 1 ) ) ; closeInterceptedStream ( stream ) ; return ; } // Send next blob readNextBlob ( stream ) ; }
Handles a single ack instruction sending yet more blobs or closing the stream depending on whether the ack indicates success or failure . If no InputStream is associated with the stream index within the ack instruction the instruction is ignored .