Package org.apache.mina.common

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


        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;
                        }
                       
                        ByteBuffer buf = ( ByteBuffer ) message;
                        if( session.getFilterChain().contains( "SSL" ) && buf.remaining() == 1 && buf.get() == ( byte ) '.' )
                        {
                            SessionLog.info( session, "TLS Reentrance" );
                            ( ( SSLFilter ) session.getFilterChain().get( "SSL" ) ).startSSL( session );

                            // Send a response
View Full Code Here

            if( req == null )
                break;

            ByteBuffer buf = ( ByteBuffer ) req.getMessage();
            if( buf.remaining() == 0 )
            {
                // pop and fire event
                synchronized( writeRequestQueue )
                {
                    writeRequestQueue.pop();
View Full Code Here

            if( req == null )
                break;

            ByteBuffer buf = ( ByteBuffer ) req.getMessage();
            if( buf.remaining() == 0 )
            {
                synchronized( writeRequestQueue )
                {
                    writeRequestQueue.pop();
                }
View Full Code Here

                    Object messageCopy = message;
                    if( message instanceof ByteBuffer )
                    {
                        ByteBuffer rb = ( ByteBuffer ) message;
                        rb.mark();
                        byteCount = rb.remaining();
                        ByteBuffer wb = ByteBuffer.allocate( rb.remaining() );
                        wb.put( rb );
                        wb.flip();
                        rb.reset();
                        messageCopy = wb;
View Full Code Here

            };
       
        encoder.encode( session, "ABC", out );
        Assert.assertEquals( 1, out.getBufferQueue().size() );
        ByteBuffer buf = ( ByteBuffer ) out.getBufferQueue().pop();
        Assert.assertEquals( 5, buf.remaining() );
        Assert.assertEquals( 'A', buf.get() );
        Assert.assertEquals( 'B', buf.get() );
        Assert.assertEquals( 'C', buf.get() );
        Assert.assertEquals( '\r', buf.get() );
        Assert.assertEquals( '\n', buf.get() );
View Full Code Here

    {
        List<byte[]> actual = new ArrayList<byte[]>();
        for (JMSBytesMessage m : received)
        {
            ByteBuffer buffer = m.getData();
            byte[] data = new byte[buffer.remaining()];
            buffer.get(data);
            actual.add(data);

            // Check Body Write Status
            try
View Full Code Here

            data = ByteBuffer.allocate(0);
        }

        if (debug)
        {
            _logger.debug("Creating message from buffer with position=" + data.position() + " and remaining=" + data
                    .remaining());
        }
        // set the properties of this message
        MessageProperties mprop;
        DeliveryProperties devprop;
View Full Code Here

        for (int i = 0; i < _chunkCount; i++)
        {
            ByteBuffer buf = ByteBuffer.allocate(_chunkSize, false);
            byte check = (byte) (i % 128);
            buf.put(check);
            buf.fill((byte) 88, buf.remaining());
            buf.flip();

            _session.write(buf);
        }
View Full Code Here

                    _logger.debug("Receieved count " + _receivedCount);
                }
            }

            ByteBuffer result = (ByteBuffer) message;
            _totalBytesReceived += result.remaining();
            int size = result.remaining();
            long now = System.currentTimeMillis();
            if (_partialBytesRead > 0)
            {
                int offset = _chunkSize - _partialBytesRead;
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.