Package org.apache.mina.common

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


                        SessionLog.debug(session, " encrypt: " + buf);
                    }

                    int pos = buf.position();
                    handler.encrypt(buf.buf());
                    buf.position(pos);
                    ByteBuffer encryptedBuffer = new EncryptedBuffer(SSLHandler
                            .copy(handler.getOutNetBuffer()), buf);

                    if (SessionLog.isDebugEnabled(session)) {
                        SessionLog.debug(session, " encrypted buf: "
View Full Code Here


        ByteBuffer expectedBuf = ByteBuffer.allocate( 160 );
        for( int i = 0; i < 10; i ++ ) {
            expectedBuf.limit( ( i + 1 ) * 16 );
            fillWriteBuffer( expectedBuf, i );
        }
        expectedBuf.position( 0 );
        assertEquals(expectedBuf, readBuf);
    }

    private void fillWriteBuffer( ByteBuffer writeBuf, int i )
    {
View Full Code Here

  public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception {
        // Decode the bytebuffer and print it to the stdout
        if (enabled && message instanceof ByteBuffer) {
            ByteBuffer byteBuffer = (ByteBuffer) message;
            // Keep current position in the buffer
            int currentPos = byteBuffer.position();
            // Decode buffer
            Charset encoder = Charset.forName("UTF-8");
            CharBuffer charBuffer = encoder.decode(byteBuffer.buf());
            // Print buffer content
            System.out.println(prefix + " - RECV (" + session.hashCode() + "): " + charBuffer);
View Full Code Here

            Charset encoder = Charset.forName("UTF-8");
            CharBuffer charBuffer = encoder.decode(byteBuffer.buf());
            // Print buffer content
            System.out.println(prefix + " - RECV (" + session.hashCode() + "): " + charBuffer);
            // Reset to old position in the buffer
            byteBuffer.position(currentPos);
        }
        // Pass the message to the next filter
        super.messageReceived(nextFilter, session, message);
    }
View Full Code Here

        ByteBuffer expectedBuf = ByteBuffer.allocate( DATA_SIZE * COUNT );
        for( int i = 0; i < COUNT; i ++ ) {
            expectedBuf.limit( ( i + 1 ) * DATA_SIZE );
            fillWriteBuffer( expectedBuf, i );
        }
        expectedBuf.position( 0 );
       
        assertEquals(expectedBuf, readBuf);
    }

    private void waitForResponse( EchoConnectorHandler handler, int bytes ) throws InterruptedException
View Full Code Here

                    // SSL encrypt
                    if (SessionLog.isDebugEnabled(session)) {
                        SessionLog.debug(session, " encrypt: " + buf);
                    }

                    int pos = buf.position();
                    handler.encrypt(buf.buf());
                    buf.position(pos);
                    ByteBuffer encryptedBuffer = new EncryptedBuffer(SSLHandler
                            .copy(handler.getOutNetBuffer()), buf);
View Full Code Here

                        SessionLog.debug(session, " encrypt: " + buf);
                    }

                    int pos = buf.position();
                    handler.encrypt(buf.buf());
                    buf.position(pos);
                    ByteBuffer encryptedBuffer = new EncryptedBuffer(SSLHandler
                            .copy(handler.getOutNetBuffer()), buf);

                    if (SessionLog.isDebugEnabled(session)) {
                        SessionLog.debug(session, " encrypted buf: "
View Full Code Here

        ByteBuffer expectedBuf = ByteBuffer.allocate( 160 );
        for( int i = 0; i < 10; i ++ ) {
            expectedBuf.limit( ( i + 1 ) * 16 );
            fillWriteBuffer( expectedBuf, i );
        }
        expectedBuf.position( 0 );
        assertEquals(expectedBuf, readBuf);
    }

    private void fillWriteBuffer( ByteBuffer writeBuf, int i )
    {
View Full Code Here

        try
        {
            for( ;; )
            {
                int oldPos = buf.position();
                if( !doDecode( session, buf, out ) )
                {
                    break;
                }
               
View Full Code Here

                if( !doDecode( session, buf, out ) )
                {
                    break;
                }
               
                if( buf.position() == oldPos )
                {
                    throw new IllegalStateException(
                            "doDecode() can't return true when buffer is not consumed." );
                }
            }
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.