Package ch.unifr.nio.framework.transform

Examples of ch.unifr.nio.framework.transform.StringToByteBufferTransformer


    private class AsyncChannelHandler extends AbstractChannelHandler {

        private final StringToByteBufferTransformer transformer;

        public AsyncChannelHandler() {
            transformer = new StringToByteBufferTransformer();
            transformer.setNextForwarder(channelWriter);
        }
View Full Code Here


        dummyTrafficOutputTransformer.setNextForwarder(sslOutputForwarder);
        ByteBufferToArrayTransformer byteBufferToArrayTransformer2 =
                new ByteBufferToArrayTransformer();
        byteBufferToArrayTransformer2.setNextForwarder(
                dummyTrafficOutputTransformer);
        StringToByteBufferTransformer stringTransformer =
                new StringToByteBufferTransformer();
        stringTransformer.setNextForwarder(byteBufferToArrayTransformer2);

        // establish the following input chain:
        // channelReader -> sslInput -> byteBufferToString -> tunnelClient
        ByteBufferToStringTransformer byteBufferToStringTransformer =
                new ByteBufferToStringTransformer();
        sslInputForwarder.setNextForwarder(byteBufferToStringTransformer);
        byteBufferToStringTransformer.setNextForwarder(
                new TunnelClientTransformer());

        // start NIO Framework
        Dispatcher dispatcher = new Dispatcher();
        dispatcher.start();
        dispatcher.registerChannel(socketChannel, this);

        // send all user input to echo server
        System.out.println("TunnelClient is running...");
        InputStreamReader reader = new InputStreamReader(System.in);
        BufferedReader stdIn = new BufferedReader(reader);
        while (true) {
            System.out.print("Your input: ");
            String userInput = stdIn.readLine();
            inputLength = userInput.length();
            if (inputLength == 0) {
                continue;
            }
            System.out.println("sending \"" + userInput + "\"");
            stringTransformer.forward(userInput);
            // wait until we get an echo from the server...
            lock.lock();
            try {
                inputArrived.await();
            } catch (InterruptedException ex) {
View Full Code Here

TOP

Related Classes of ch.unifr.nio.framework.transform.StringToByteBufferTransformer

Copyright © 2018 www.massapicom. 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.