private GuacamoleInstruction expect ( GuacamoleReader reader , String opcode ) throws GuacamoleException { // Wait for an instruction GuacamoleInstruction instruction = reader . readInstruction ( ) ; if ( instruction == null ) throw new GuacamoleServerException ( "End of stream while waiting for \"" + opcode + "\"." ) ; // Ensure instruction has expected opcode if ( ! instruction . getOpcode ( ) . equals ( opcode ) ) throw new GuacamoleServerException ( "Expected \"" + opcode + "\" instruction but instead received \"" + instruction . getOpcode ( ) + "\"." ) ; return instruction ; }
Waits for the instruction having the given opcode returning that instruction once it has been read . If the instruction is never read an exception is thrown .