@Override
    public GuacamoleInstruction readInstruction() throws GuacamoleException {

        GuacamoleInstruction filteredInstruction;

        // Read and filter instructions until no instructions are dropped
        do {

            // Read next instruction
            GuacamoleInstruction unfilteredInstruction = reader.readInstruction();
            if (unfilteredInstruction == null)
                return null;

            // Apply filter
            filteredInstruction = filter.filter(unfilteredInstruction);

        } while (filteredInstruction == null);

        return filteredInstruction;
        
    }
Wraps the given GuacamoleReader, applying the given filter to all read
instructions. Future reads will return only instructions which pass
the filter.

@param reader The GuacamoleReader to wrap.
@param filter The filter which dictates which instructions are read, and
              how.
guacamole-common/src/main/java/org/apache/guacamole/protocol/FilteredGuacamoleReader.java