Package org.apache.mina.common

Examples of org.apache.mina.common.ByteBuffer.rewind()


        }

        public void messageSent( IoSession session, Object message ) throws Exception
        {
            ByteBuffer buffer = ( ByteBuffer ) 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


        byte[] actual = receivedMessages.get(0);

        assertTrue("Incorrect recv!", Arrays.equals(actual, expected));

        harness.recv(buf.rewind());

        assertEquals(0, sentMessages.size());
        assertEquals(2, receivedMessages.size());

        actual = receivedMessages.get(1);
View Full Code Here

        // Do the recvs
        for (int i = 0; i < 7; ++i) {
            assertEquals(0, sentMessages.size());
            assertEquals(0, receivedMessages.size());

            buf.rewind();
            buf.get(expected, i * 1024, 1024);
            buf.rewind();
            harness.recv(buf);
        }

View Full Code Here

            assertEquals(0, sentMessages.size());
            assertEquals(0, receivedMessages.size());

            buf.rewind();
            buf.get(expected, i * 1024, 1024);
            buf.rewind();
            harness.recv(buf);
        }

        assertEquals(0, sentMessages.size());
        assertEquals(1, receivedMessages.size());
View Full Code Here

        assertEquals(0, sentMessages.size());
        assertEquals(1, receivedMessages.size());

        harness.recv(sizeBuf.rewind().asReadOnlyBuffer());
        harness.recv(buf.rewind());

        assertEquals(0, sentMessages.size());
        assertEquals(2, receivedMessages.size());

        actual = receivedMessages.get(1);
View Full Code Here

        harness.recv(buf);
        assertEquals(0, sentMessages.size());
        assertEquals(0, receivedMessages.size());

        // Send a second message, expecting the first to have been dropped.
        buf.rewind();
        harness.recv(buf);

        assertEquals(0, sentMessages.size());
        assertEquals(1, receivedMessages.size());
    }
View Full Code Here

        }

        public void messageSent( IoSession session, Object message ) throws Exception
        {
            ByteBuffer buffer = ( ByteBuffer ) 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

        }

        public void messageSent(IoSession session, Object message)
                throws Exception {
            ByteBuffer buffer = (ByteBuffer) 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 null;
    }

    ByteBuffer result = ByteBuffer.allocate(this.dataCount);
    result.put(this.blockData, 0, this.dataCount);
    result.rewind();
    return result;
  }
}
View Full Code Here

      System.arraycopy(this.blockData, pos, tmpData, 0, size);
      result.put(tmpData, 0, size);
      pos += this.blockDataSize;
    }

    result.rewind();
    return result;
  }

}
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.