Package ch.unifr.nio.framework.transform

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


        public OutputHandler() {
            setDaemon(false);

            // setup output transformation chain:
            // stringToByteBuffer -> channelWriter
            transformer = new StringToByteBufferTransformer();
            transformer.setNextForwarder(channelWriter);
        }
View Full Code Here


                byteBufferArraySequenceForwarder);
        ByteBufferToArrayTransformer byteBufferToArrayTransformer =
                new ByteBufferToArrayTransformer();
        byteBufferToArrayTransformer.setNextForwarder(
                dummyTrafficOutputTransformer);
        stringToByteBufferTransformer = new StringToByteBufferTransformer();
        stringToByteBufferTransformer.setNextForwarder(
                byteBufferToArrayTransformer);

        // connect to server
        InetSocketAddress socketAddress =
View Full Code Here

        channelReader.setNextForwarder(byteBufferToStringTransformer);
        EchoClientTransformer echoTransformer = new EchoClientTransformer();
        byteBufferToStringTransformer.setNextForwarder(echoTransformer);

        // setup output chain
        StringToByteBufferTransformer stringToByteBufferTransformer =
                new StringToByteBufferTransformer();
        stringToByteBufferTransformer.setNextForwarder(channelWriter);

        try {
            // connect to server
            InetSocketAddress socketAddress =
                    new InetSocketAddress(host, port);
            SocketChannel channel = SocketChannel.open(socketAddress);
            channel.configureBlocking(false);

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

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

                byteBufferArraySequenceForwarder);
        ByteBufferToArrayTransformer byteBufferToArrayTransformer =
                new ByteBufferToArrayTransformer();
        byteBufferToArrayTransformer.setNextForwarder(
                dummyTrafficOutputTransformer);
        StringToByteBufferTransformer stringToByteBufferTransformer =
                new StringToByteBufferTransformer();
        stringToByteBufferTransformer.setNextForwarder(
                byteBufferToArrayTransformer);

        try {
            // connect to server
            InetSocketAddress socketAddress =
                    new InetSocketAddress(host, port);
            SocketChannel channel = SocketChannel.open(socketAddress);
            channel.configureBlocking(false);

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

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

        public OutputHandler() {
            setDaemon(false);

            // setup output transformation chain:
            // stringToByteBuffer -> channelWriter
            transformer = new StringToByteBufferTransformer();
            transformer.setNextForwarder(channelWriter);
        }
View Full Code Here

        super(socketChannel, sslContext, true, 1500, 15000, 1000);

        // establish the following output chain:
        // stringToByteBuffer -> byteBufferToArray -> sslOutput -> channelWriter
        StringToByteBufferTransformer stringOutTransformer =
                new StringToByteBufferTransformer();
        stringOutTransformer.setNextForwarder(byteBufferToArrayTransformer);

        // establish the following input chain:
        // channelReader -> sslInput -> byteBufferToString -> sslEchoClient
        ByteBufferToStringTransformer toStringTransformer =
                new ByteBufferToStringTransformer();
        sslInputForwarder.setNextForwarder(toStringTransformer);
        toStringTransformer.setNextForwarder(new SSLEchoClientTransformer());

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

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

        EchoTransformer echoTransformer = new EchoTransformer();
        byteBufferToStringTransformer.setNextForwarder(echoTransformer);


        // setup output chain
        StringToByteBufferTransformer stringToByteBufferTransformer =
                new StringToByteBufferTransformer();
        stringToByteBufferTransformer.setNextForwarder(channelWriter);

        try {
            // connect to server
            InetSocketAddress socketAddress =
                    new InetSocketAddress(host, port);
View Full Code Here

        testChannelHandler.waitForInputClosed();

        logger.finest(
                "trigger another selection round by blocking write operation");
        ChannelWriter channelWriter = testChannelHandler.getChannelWriter();
        StringToByteBufferTransformer transformer =
                new StringToByteBufferTransformer();
        transformer.setNextForwarder(channelWriter);
        transformer.forward(
                "this must block and trigger another selection round");

        logger.finest("push dispatcher some selection rounds forward");
        // (we REALLY need two calls here as the first round does not have the
        // incomplete write in its selected set...)
View Full Code Here

        Thread testThread = new Thread() {

            @Override
            public void run() {
                try {
                    StringToByteBufferTransformer transformer =
                            new StringToByteBufferTransformer();
                    transformer.setNextForwarder(channelWriter);
                    transformer.forward("this MUST BLOCK right now!");
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        };
View Full Code Here

        framingOutputTransformer.setNextForwarder(bufferTransformer);
        ByteBufferToArrayTransformer byteBufferToArrayTransformer =
                new ByteBufferToArrayTransformer();
        byteBufferToArrayTransformer.setNextForwarder(
                framingOutputTransformer);
        StringToByteBufferTransformer stringToByteBufferTransformer =
                new StringToByteBufferTransformer();
        stringToByteBufferTransformer.setNextForwarder(
                byteBufferToArrayTransformer);

        try {
            // connect to server
            InetSocketAddress socketAddress =
                    new InetSocketAddress(host, port);
            SocketChannel channel = SocketChannel.open(socketAddress);
            channel.configureBlocking(false);

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

            // send all user input to framing server
            System.out.println("FramingClient is running...");
            InputStreamReader streamReader = new InputStreamReader(System.in);
            BufferedReader stdIn = new BufferedReader(streamReader);
            while (true) {
                System.out.print("Your input: ");
                String userInput = stdIn.readLine();
                inputLength = userInput.length();
                if (inputLength == 0) {
                    continue;
                }
                System.out.println("sending \"" + userInput + "\"");
                stringToByteBufferTransformer.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.