Package org.apache.mina.common

Examples of org.apache.mina.common.IoBuffer.flip()


            if (message instanceof IoBuffer) {
                IoBuffer rb = (IoBuffer) message;
                rb.mark();
                IoBuffer wb = IoBuffer.allocate(rb.remaining());
                wb.put(rb);
                wb.flip();
                rb.reset();
                messageCopy = wb;
            }
            return messageCopy;
        }
View Full Code Here


        buf.putString(value, encoder);
        if (buf.position() > maxLineLength) {
            throw new IllegalArgumentException("Line length: " + buf.position());
        }
        buf.putString(delimiter.getValue(), encoder);
        buf.flip();
        out.write(buf);
    }

    public void dispose() throws Exception {
    }
View Full Code Here

     * @return the new buffer, ready to read from
     */
    public static IoBuffer copy(ByteBuffer src) {
        IoBuffer copy = IoBuffer.allocate(src.remaining());
        copy.put(src);
        copy.flip();
        return copy;
    }
}
View Full Code Here

                newBuff.put((byte) (rng.nextInt(256)));
            }
            while (buffer.remaining() > 0) {
                newBuff.put(buffer.get());
            }
            newBuff.flip();

            logger.info("Inserted " + count + " bytes.");
            logger.info(newBuff.getHexDump());
            return newBuff;
        }
View Full Code Here

                newBuff.put(buffer.get());

            buffer.skip(count); // hole
            while (newBuff.remaining() > 0)
                newBuff.put(buffer.get());
            newBuff.flip();
            // copy the new buffer in the old one
            buffer.rewind();
            buffer.put(newBuff);
            buffer.flip();
            logger.info("Removed " + count + " bytes at position " + pos + ".");
View Full Code Here

    private void sendData() throws InterruptedException {
        for (int i = 0; i < 30; i++) {
            long free = Runtime.getRuntime().freeMemory();
            IoBuffer buffer = IoBuffer.allocate(8);
            buffer.putLong(free);
            buffer.flip();
            session.write(buffer);

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
View Full Code Here

            throws Exception {
        IoBuffer rb = (IoBuffer) message;
        IoBuffer wb = IoBuffer.allocate(rb.remaining());
        rb.mark();
        wb.put(rb);
        wb.flip();
        ((IoSession) session.getAttribute("")).write(wb);
        rb.reset();
        logger.info(rb.getString(CHARSET.newDecoder()));
    }
}
View Full Code Here

    @Override
    public void write(int b) throws IOException {
        IoBuffer buf = IoBuffer.allocate(1);
        buf.put((byte) b);
        buf.flip();
        write(buf);
    }

    @Override
    public synchronized void flush() throws IOException {
View Full Code Here

                            + retval + " and message : " + zStream.msg);
                }
            }
        } while (zStream.avail_in > 0);

        return outBuffer.flip();
    }

    /**
     * @param inBuffer the buffer to be compressed. The contents are transferred
     * into a local byte array and the buffer is flipped and returned intact.
View Full Code Here

                                    .startSsl(session);

                            // Send a response
                            buf = IoBuffer.allocate(1);
                            buf.put((byte) '.');
                            buf.flip();
                            session
                                    .setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE);
                            session.write(buf);
                        } else {
                            super.messageReceived(session, message);
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.