Package org.apache.mina.core.buffer

Examples of org.apache.mina.core.buffer.IoBuffer.remaining()


        bb.clear();
        Cursor cursor = ba.cursor();
        assertEquals(0, cursor.getIndex());
        assertEquals(1, cursor.getRemaining());
        assertEquals(0, bb.position());
        assertEquals(2, bb.remaining());
        cursor.get(bb);
        assertEquals(1, cursor.getIndex());
        assertEquals(0, cursor.getRemaining());
        assertEquals(1, bb.position());
        assertEquals(1, bb.remaining());
View Full Code Here


        assertEquals(2, bb.remaining());
        cursor.get(bb);
        assertEquals(1, cursor.getIndex());
        assertEquals(0, cursor.getRemaining());
        assertEquals(1, bb.position());
        assertEquals(1, bb.remaining());
    }
   
    @Test
    public void testCompositeByteArrayPrimitiveAccess() {
        CompositeByteArray cbaBig = new CompositeByteArray();
View Full Code Here

        @Override
        public void messageReceived(IoSession session, Object message)
                throws Exception {
            IoBuffer buffer = (IoBuffer) message;
            byte[] data = new byte[buffer.remaining()];
            buffer.get(data);
            Object lock = session.getAttribute("lock");
            synchronized (lock) {
                StringBuffer sb = (StringBuffer) session
                        .getAttribute("received");
View Full Code Here

        @Override
        public void messageSent(IoSession session, Object message)
                throws Exception {
            IoBuffer buffer = (IoBuffer) message;
            buffer.rewind();
            byte[] data = new byte[buffer.remaining()];
            buffer.get(data);
            StringBuffer sb = (StringBuffer) session.getAttribute("sent");
            sb.append(new String(data, "ASCII"));
        }
View Full Code Here

            return false;
        }
       
        IoBuffer buf = (IoBuffer) message;
        int offset = buf.position();
        return buf.remaining() == 23 &&
               buf.get(offset + 0) == 0x15 && buf.get(offset + 1) == 0x03 &&
               buf.get(offset + 2) == 0x01 && buf.get(offset + 3) == 0x00 &&
               buf.get(offset + 4) == 0x12;
    }
View Full Code Here

                    session.setCurrentWriteRequest(req);
                }

                IoBuffer buf = (IoBuffer) req.getMessage();
               
                if (buf.remaining() == 0) {
                    // Clear and fire event
                    session.setCurrentWriteRequest(null);
                    buf.reset();
                    session.getFilterChain().fireMessageSent(req);
                    continue;
View Full Code Here

  }

  @Override
  public void messageReceived(IoSession session, Object message) throws Exception {
    IoBuffer msg = (IoBuffer) message;
    logger.info("MESSAGE: " + msg.remaining() + " on session " + session.getId() );
    final int rec = received.incrementAndGet();
   
    if (rec == MSG_COUNT) {
      synchronized (LOCK) {
        LOCK.notifyAll();
View Full Code Here

                    IoBuffer tmp = decoder.decodeFully(buf);
                    if (tmp == null) {
                        return;
                    }

                    if (tmp.remaining() == 2) {
                        waitingFooters = false;
                        break;
                    }

                    // add footer to headers                   
View Full Code Here

       
        if (buf.hasRemaining()) {
            int length;
           
            if (hasFragmentation) {
                length = Math.min(buf.remaining(), maxLength);
            } else {
                length = buf.remaining();
            }
           
            localWrittenBytes = write(session, buf, length);
View Full Code Here

            int length;
           
            if (hasFragmentation) {
                length = Math.min(buf.remaining(), maxLength);
            } else {
                length = buf.remaining();
            }
           
            localWrittenBytes = write(session, buf, length);
        }
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.