Examples of GuacamoleInstruction


Examples of org.glyptodon.guacamole.protocol.GuacamoleInstruction

        // Pull opcode off elements list
        String opcode = elements.removeFirst();

        // Create instruction
        GuacamoleInstruction instruction = new GuacamoleInstruction(
                opcode,
                elements.toArray(new String[elements.size()])
        );

        // Return parsed instruction
View Full Code Here

Examples of org.glyptodon.guacamole.protocol.GuacamoleInstruction

    @Override
    public char[] read() throws GuacamoleException {

        // Read single instruction, handle end-of-stream
        GuacamoleInstruction instruction = readInstruction();
        if (instruction == null)
            return null;

        return instruction.toString().toCharArray();

    }
View Full Code Here

Examples of org.glyptodon.guacamole.protocol.GuacamoleInstruction

    @Override
    public GuacamoleInstruction readInstruction() throws GuacamoleException {

        // Read single instruction, handle end-of-stream
        GuacamoleInstruction instruction = reader.readInstruction();
        if (instruction == null)
            return null;

        // If clipboard changing, reset clipboard state
        if (instruction.getOpcode().equals("clipboard")) {
            List<String> args = instruction.getArgs();
            if (args.size() >= 2) {
                clipboard_stream_index = args.get(0);
                clipboard.begin(args.get(1));
            }
        }

        // Add clipboard blobs to existing streams
        else if (instruction.getOpcode().equals("blob")) {
            List<String> args = instruction.getArgs();
            if (args.size() >= 2 && args.get(0).equals(clipboard_stream_index)) {
                String base64 = args.get(1);
                clipboard.append(DatatypeConverter.parseBase64Binary(base64));
            }
        }
       
        // Terminate and update clipboard at end of stream
        else if (instruction.getOpcode().equals("end")) {
            List<String> args = instruction.getArgs();
            if (args.size() >= 1 && args.get(0).equals(clipboard_stream_index)) {
                clipboard.commit();
                clipboard_stream_index = null;
            }
        }
View Full Code Here

Examples of org.glyptodon.guacamole.protocol.GuacamoleInstruction

        // Test string
        final String test = "1.a,2.bc,3.def,10.helloworld;4.test,5.test2;0.;3.foo;";

        GuacamoleReader reader = new ReaderGuacamoleReader(new StringReader(test));

        GuacamoleInstruction instruction;

        // Validate first test instruction
        instruction = reader.readInstruction();
        assertNotNull(instruction);
        assertEquals(3, instruction.getArgs().size());
        assertEquals("a", instruction.getOpcode());
        assertEquals("bc", instruction.getArgs().get(0));
        assertEquals("def", instruction.getArgs().get(1));
        assertEquals("helloworld", instruction.getArgs().get(2));

        // Validate second test instruction
        instruction = reader.readInstruction();
        assertNotNull(instruction);
        assertEquals(1, instruction.getArgs().size());
        assertEquals("test", instruction.getOpcode());
        assertEquals("test2", instruction.getArgs().get(0));

        // Validate third test instruction
        instruction = reader.readInstruction();
        assertNotNull(instruction);
        assertEquals(0, instruction.getArgs().size());
        assertEquals("", instruction.getOpcode());

        // Validate fourth test instruction
        instruction = reader.readInstruction();
        assertNotNull(instruction);
        assertEquals(0, instruction.getArgs().size());
        assertEquals("foo", instruction.getOpcode());

        // There should be no more instructions
        instruction = reader.readInstruction();
        assertNull(instruction);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.