Examples of IoBuffer


Examples of org.apache.mina.core.buffer.IoBuffer

        NioSocketAcceptor acceptor = new NioSocketAcceptor();
        acceptor.setHandler(new IoHandlerAdapter() {
            @Override
            public void messageReceived(IoSession session, Object message) throws Exception {
                IoBuffer recv = (IoBuffer) message;
                IoBuffer sent = IoBuffer.allocate(recv.remaining());
                sent.put(recv);
                sent.flip();
                session.write(sent);
            }
        });
        acceptor.setReuseAddress(true);
        acceptor.bind(new InetSocketAddress(echoPort));
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

   */
  @Test
  public void testFragmented() throws CharacterCodingException {
    final int maxLen = 100;

    IoBuffer savedBuf = IoBuffer.allocate(maxLen);

    String origMsg = "<1>- - blah blam foo\n";
    IoBuffer buf1 = IoBuffer.wrap(
        origMsg.substring(0, 11).getBytes(Charsets.UTF_8));
    IoBuffer buf2 = IoBuffer.wrap(
        origMsg.substring(11, 16).getBytes(Charsets.UTF_8));
    IoBuffer buf3 = IoBuffer.wrap(
        origMsg.substring(16, 21).getBytes(Charsets.UTF_8));

    LineSplitter lineSplitter = new LineSplitter(maxLen);
    ParsedBuffer parsedLine = new ParsedBuffer();

View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

    String dangerousChars = "þÿÀÁ";

    ///////////////////////////////////////////////////////
    // encode and send them through the message handler
    String msg;
    IoBuffer buf;
    Event evt;

    // valid ISO-8859-1 on the right (ISO-8859-1) port
    msg = header + dangerousChars + "\n";
    buf = IoBuffer.wrap(msg.getBytes(Charsets.ISO_8859_1));
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

        this.charset = charset;
        this.delimiter = delimiter;
       
        // Convert delimiter to ByteBuffer if not done yet.
        if (delimBuf == null) {
            IoBuffer tmp = IoBuffer.allocate(2).setAutoExpand(true);
           
            try{
                tmp.putString(delimiter.getValue(), charset.newEncoder());
            } catch (CharacterCodingException cce) {
               
            }
           
            tmp.flip();
            delimBuf = tmp;
        }
    }
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

                in.limit(oldLimit);
                in.position(pos);

                if (ctx.getOverflowPosition() == 0) {
                    IoBuffer buf = ctx.getBuffer();
                    buf.flip();
                    buf.limit(buf.limit() - matchCount);
                   
                    try {
                        writeText(session, buf.getString(ctx.getDecoder()), out);
                    } finally {
                        buf.clear();
                    }
                } else {
                    int overflowPosition = ctx.getOverflowPosition();
                    ctx.reset();
                    throw new RecoverableProtocolDecoderException(
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

                    in.limit(oldLimit);
                    in.position(pos);
                   
                    if (ctx.getOverflowPosition() == 0) {
                        IoBuffer buf = ctx.getBuffer();
                        buf.flip();
                        buf.limit(buf.limit() - matchCount);
                       
                        try {
                            writeText(session, buf.getString(ctx.getDecoder()), out);
                        } finally {
                            buf.clear();
                        }
                    } else {
                        int overflowPosition = ctx.getOverflowPosition();
                        ctx.reset();
                        throw new RecoverableProtocolDecoderException(
View Full Code Here

Examples of org.apache.tomcat.lite.io.IOBuffer

            mOutBuffer = sc;
        }

        @Override
        public void handleReceived(IOChannel ch) throws IOException {
            IOBuffer inBuffer = ch.getIn();
            IOChannel outBuffer = mOutBuffer;
            if (outBuffer == null &&
                    ch instanceof HttpChannel) {
                outBuffer =
                    (IOChannel) ((HttpChannel)ch).getRequest().getAttribute("P");
            }
            // body.
            while (true) {
                if (outBuffer == null || outBuffer.getOut() == null) {
                    return;
                }
                if (outBuffer.getOut().isAppendClosed()) {
                    return;
                }

                ByteBuffer bb = outBuffer.getOut().getWriteBuffer();
                int rd = inBuffer.read(bb);
                outBuffer.getOut().releaseWriteBuffer(rd);

                if (rd == 0) {
                    outBuffer.startSending();
                    return;
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.