Package org.apache.mina.example.imagine.step1.client

Examples of org.apache.mina.example.imagine.step1.client.ImageClient


        ImageRequest request = (ImageRequest) message;
        String text1 = generateString(session, request.getNumberOfCharacters());
        String text2 = generateString(session, request.getNumberOfCharacters());
        BufferedImage image1 = createImage(request, text1);
        BufferedImage image2 = createImage(request, text2);
        ImageResponse response = new ImageResponse(image1, image2);
        session.write(response);
    }
View Full Code Here


            session.write(imageRequest);
        }
    }

    public void messageReceived(IoSession session, Object message) throws Exception {
        ImageResponse response = (ImageResponse) message;
        imageListener.onImages(response.getImage1(), response.getImage2());
    }
View Full Code Here

* @author The Apache MINA Project (dev@mina.apache.org)
*/
public class ImageResponseEncoder extends ProtocolEncoderAdapter {

    public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
        ImageResponse imageResponse = (ImageResponse) message;
        byte[] bytes1 = getBytes(imageResponse.getImage1());
        byte[] bytes2 = getBytes(imageResponse.getImage2());
        int capacity = bytes1.length + bytes2.length + 8;
        IoBuffer buffer = IoBuffer.allocate(capacity, false);
        buffer.putInt(bytes1.length);
        buffer.put(bytes1);
        buffer.putInt(bytes2.length);
View Full Code Here

        }
        if (decoderState.image1 != null) {
            // try to read second image
            if (in.prefixedDataAvailable(4, MAX_IMAGE_SIZE)) {
                BufferedImage image2 = readImage(in);
                ImageResponse imageResponse = new ImageResponse(decoderState.image1, image2);
                out.write(imageResponse);
                decoderState.image1 = null;
                return true;
            } else {
                // not enough data available to read second image
View Full Code Here

    public ImageClient(String host, int port, ImageListener imageListener) {
        this.host = host;
        this.port = port;
        this.imageListener = imageListener;
        connector = new NioSocketConnector();
        connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ImageCodecFactory(true)));
        connector.setHandler(this);
    }
View Full Code Here

        // This socket acceptor will handle incoming connections
        NioSocketAcceptor acceptor = new NioSocketAcceptor();
       
        // add an IoFilter .  This class is responsible for converting the incoming and
        // outgoing raw data to ImageRequest and ImageResponse objects
        acceptor.getFilterChain().addLast("protocol", new ProtocolCodecFilter(new ImageCodecFactory(false)));
       
        // get a reference to the filter chain from the acceptor
        DefaultIoFilterChainBuilder filterChainBuilder = acceptor.getFilterChain();
       
        // add an ExecutorFilter to the filter chain.  The preferred order is to put the executor filter
View Full Code Here

        // this acceptor.
        mBeanServer.registerMBean( acceptorMBean, acceptorName );
       
        // add an IoFilter .  This class is responsible for converting the incoming and
        // outgoing raw data to ImageRequest and ImageResponse objects
        ProtocolCodecFilter protocolFilter = new ProtocolCodecFilter(new ImageCodecFactory(false));
       
        // create a JMX-aware bean that wraps a MINA IoFilter object.  In this
        // case, a ProtocolCodecFilter
        IoFilterMBean protocolFilterMBean = new IoFilterMBean( protocolFilter );
       
View Full Code Here

        // This socket acceptor will handle incoming connections
        NioSocketAcceptor acceptor = new NioSocketAcceptor();
       
        // add an IoFilter .  This class is responsible for converting the incoming and
        // outgoing raw data to ImageRequest and ImageResponse objects
        acceptor.getFilterChain().addLast("protocol", new ProtocolCodecFilter(new ImageCodecFactory(false)));
       
        // set this NioSocketAcceptor's handler to the ImageServerHandler
        acceptor.setHandler(handler);
       
        // Bind to the specified address.  This kicks off the listening for
View Full Code Here

    public ImageClient(String host, int port, ImageListener imageListener) {
        this.host = host;
        this.port = port;
        this.imageListener = imageListener;
        connector = new NioSocketConnector();
        connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ImageCodecFactory(true)));
        connector.setHandler(this);
    }
View Full Code Here

    public ImageClient(String host, int port, ImageListener imageListener) {
        this.host = host;
        this.port = port;
        this.imageListener = imageListener;
        connector = new NioSocketConnector();
        connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ImageCodecFactory(true)));
        connector.setHandler(this);
    }
View Full Code Here

TOP

Related Classes of org.apache.mina.example.imagine.step1.client.ImageClient

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.