Package org.gudy.azureus2.core3.util

Examples of org.gudy.azureus2.core3.util.DirectByteBuffer


          break;
        }
       
        payload_buffer.flip();
       
        messages.add( new GenericMessage( msg_type, msg_desc, new DirectByteBuffer( payload_buffer ), false ));
       
        buffers[1= null;
      }
     
      total_read += bytes_read;
View Full Code Here


    if( core_msg == null ) {
      return plug_msg.create( data );
    }
   
    try{
      return new MessageAdapter( core_msg.deserialize( new DirectByteBuffer( data ), (byte)1 ) );
    }
    catch( com.aelitis.azureus.core.peermanager.messaging.MessageException e ) {
      throw new MessageException( e.getMessage() );
    }
  }
View Full Code Here

    }
   
    ByteBuffer[] bbs = plug_msg.getPayload();
    DirectByteBuffer[] dbbs = new DirectByteBuffer[ bbs.length ]//TODO cache it???
    for( int i=0; i < bbs.length; i++ ) {
      dbbs[i] = new DirectByteBuffer( bbs[i] );
    }
    return dbbs;
  }
View Full Code Here

          List<byte[]>  replies = (List<byte[]>)reply.get( "data" );
         
          for (int i=0;i<replies.size();i++){
             
            owner.receive( new GenericMessage(msg_id, msg_desc, new DirectByteBuffer(ByteBuffer.wrap(replies.get(i))), false ));
          }
         
        }else{
         
          Debug.out( "Unexpected reply type - " + reply_type );
View Full Code Here

         
          List<byte[]>  replies = (List<byte[]>)reply.get( "data" );
                     
          for (int i=0;i<replies.size();i++){
             
            owner.receive( new GenericMessage(msg_id, msg_desc, new DirectByteBuffer(ByteBuffer.wrap(replies.get(i))), false ));
          }
         
            // if there's more data queued force a keep alive to pick it up but delay
            // a little to give the rendezvous a breather
         
View Full Code Here

   
    last_message_received  = SystemTime.getCurrentTime();
   
    for (int i=0;i<messages.size();i++){
     
      owner.receive( new GenericMessage(msg_id, msg_desc, new DirectByteBuffer(ByteBuffer.wrap(messages.get(i))), false ));
    }
   
    List<byte[]>  reply = new ArrayList<byte[]>();
   
      // hang around a bit to see if we can piggyback a reply
View Full Code Here

   
    ByteBuffer  initial_data = ByteBuffer.wrap( msg_id.getBytes());
   
    if ( upper_initial_data != null ){
   
      GenericMessage  gm = new GenericMessage( msg_id, msg_desc, new DirectByteBuffer( upper_initial_data ), false );
     
      DirectByteBuffer[]  payload = new GenericMessageEncoder().encodeMessage( gm )[0].getRawData();
     
      int  size = initial_data.remaining();
     
      for (int i=0;i<payload.length;i++){
       
        size += payload[i].remaining( DirectByteBuffer.SS_MSG );
      }
     
      ByteBuffer  temp = ByteBuffer.allocate( size );
     
      temp.put( initial_data );
     
      for (int i=0;i<payload.length;i++){
     
        temp.put( payload[i].getBuffer( DirectByteBuffer.SS_MSG ));
      }
     
      temp.rewind();
     
      initial_data = temp;
    }
           
    connection.connect(
        initial_data,
        ProtocolEndpoint.CONNECT_PRIORITY_MEDIUM,
        new NetworkConnection.ConnectionListener()
        {
          public int
          connectStarted(
            int default_connect_timeout )
          { 
            return( default_connect_timeout );
          }
         
          public void
          connectSuccess(
            ByteBuffer remaining_initial_data )
          {
            connected  = true;
                           
            try{
               
                if ( remaining_initial_data != null && remaining_initial_data.remaining() > 0){
                 
                    // queue as a *raw* message as already encoded
                 
                connection.getOutgoingMessageQueue().addMessage(
                    new GenericMessagemsg_id, msg_desc, new DirectByteBuffer( remaining_initial_data ), true), false );
                }
               
                listener.connectSuccess();
             
              startProcessing();
View Full Code Here

  encodeMessage(
    Message _message )
  {
    GenericMessage  message = (GenericMessage)_message;
   
    DirectByteBuffer  payload = message.getPayload();
   
    if ( message.isAlreadyEncoded()){
     
      return(
        new RawMessage[]{
          new RawMessageImpl(
            message,
            new DirectByteBuffer[]{ payload },
            RawMessage.PRIORITY_NORMAL,
            true,  // send immediately
            new Message[0] )});
     
    }else{
     
      DirectByteBuffer   header = DirectByteBufferPool.getBuffer( DirectByteBuffer.AL_EXTERNAL, 4 );
     
      header.putInt( DirectByteBuffer.SS_MSG, payload.remaining( DirectByteBuffer.SS_MSG ));
     
      header.flip( DirectByteBuffer.SS_MSG );
     
      return(
        new RawMessage[]{
          new RawMessageImpl(
            message,
View Full Code Here

           
              // pick up any remaining data for delivery
           
            if ( in_buffer.hasRemaining()){
             
              message = new PooledByteBufferImpl( new DirectByteBuffer( in_buffer.slice()));
             
              forward  = true;
            }
          }
        }
      }
       
      if ( out_buffer != null ){
       
        out_buffer.flip();
       
        connection.send( new PooledByteBufferImpl( new DirectByteBuffer( out_buffer )));
      }
     
      if ( crypto_completed ){
       
        cryptoComplete();
View Full Code Here

            if ( len > max_read_chunk ){
           
              len = max_read_chunk;
            }
           
            DirectByteBuffer buffer = core_file.read( pos, (int)len );
 
            inform( new event( new PooledByteBufferImpl( buffer ), pos, (int)len ));
           
            pos += len;
           
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.util.DirectByteBuffer

Copyright © 2018 www.massapicom. 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.