Examples of RawMessage


Examples of com.aelitis.azureus.core.networkmanager.RawMessage

  {
    String  id = message.getID();
   
    // System.out.println( "encodeMessage: " + message.getID());
   
    RawMessage  raw_message = null;
   
    if ( id.equals( BTMessage.ID_BT_HANDSHAKE )){
   
      raw_message = http_connection.encodeHandShake( message );
     
View Full Code Here

Examples of com.aelitis.azureus.core.networkmanager.RawMessage

      return;
    }
   
    for (int i=0;i<rmesgs.length;i++){
     
      RawMessage rmesg = rmesgs[i];
     
      removeMessagesOfType( rmesg.messagesToRemove(), manual_listener_notify );
     
      try{
        queue_mon.enter();
     
        int pos = 0;
        for( Iterator it = queue.iterator(); it.hasNext(); ) {
          RawMessage msg = (RawMessage)it.next();
          if( rmesg.getPriority() > msg.getPriority()
            && msg.getRawData()[0].position(DirectByteBuffer.SS_NET) == 0 ) {  //but don't insert in front of a half-sent message
            break;
          }
          pos++;
        }
        if( rmesg.isNoDelay() ) {
View Full Code Here

Examples of com.aelitis.azureus.core.networkmanager.RawMessage

   
    try{
      queue_mon.enter();
   
      for( Iterator i = queue.iterator(); i.hasNext(); ) {
        RawMessage msg = (RawMessage)i.next();
       
        for( int t=0; t < message_types.length; t++ ) {
          boolean same_type = message_types[t].getID().equals( msg.getID() );
         
          if( same_type && msg.getRawData()[0].position(DirectByteBuffer.SS_NET) == 0 ) {   //dont remove a half-sent message
            if( msg == urgent_message ) urgent_message = null;
           
            DirectByteBuffer[] payload = msg.getRawData();
            int remaining = 0;
            for( int x=0; x < payload.length; x++ ) {
              remaining += payload[x].remaining(DirectByteBuffer.SS_NET);
            }
            total_size -= remaining;
            if ( msg.getType() == Message.TYPE_DATA_PAYLOAD ){
              total_data_size -= remaining;
            }
            if( manual_listener_notify ) {
              NotificationItem item = new NotificationItem( NotificationItem.MESSAGE_REMOVED );
              item.message = msg;
              try {
                delayed_notifications_mon.enter();
               
                delayed_notifications.add( item );
              }
              finally {
                delayed_notifications_mon.exit();
              }
            }
            else {
              if ( messages_removed == null ){
                messages_removed = new ArrayList();
              }
              messages_removed.add( msg );
            }
            i.remove();
            break;
          }
        }
      }
     
      if ( queue.isEmpty()){
        percent_complete = -1;
      }
    }finally{
      queue_mon.exit();
    }

    if( !manual_listener_notify && messages_removed != null ) {
      //do listener notifications now
      ArrayList listeners_ref = listeners;
       
      for( int x=0; x < messages_removed.size(); x++ ) {
        RawMessage msg = (RawMessage)messages_removed.get( x );
       
        for( int i=0; i < listeners_ref.size(); i++ ) {
          MessageQueueListener listener = (MessageQueueListener)listeners_ref.get( i );
          listener.messageRemoved( msg.getBaseMessage() );
        }
        msg.destroy();
      }
    }
  }
View Full Code Here

Examples of com.aelitis.azureus.core.networkmanager.RawMessage

   * @param message to remove
   * @param manual_listener_notify true for manual notification, false for automatic
   * @return true if the message was removed, false otherwise
   */
  public boolean removeMessage( Message message, boolean manual_listener_notify ) {
    RawMessage msg_removed = null;
   
    try{
      queue_mon.enter();

      for( Iterator it = queue.iterator(); it.hasNext(); ) {
        RawMessage raw = (RawMessage)it.next();
       
        if( message.equals( raw.getBaseMessage() ) ) {
          if( raw.getRawData()[0].position(DirectByteBuffer.SS_NET) == 0 ) {  //dont remove a half-sent message
            if( raw == urgent_message ) urgent_message = null
           
            DirectByteBuffer[] payload = raw.getRawData();
            int remaining = 0;
            for( int x=0; x < payload.length; x++ ) {
              remaining += payload[x].remaining(DirectByteBuffer.SS_NET);
            }
            total_size -= remaining;
            if ( raw.getType() == Message.TYPE_DATA_PAYLOAD ){
              total_data_size -= remaining;
            }
            queue.remove( raw );
            msg_removed = raw;
          }
View Full Code Here

Examples of com.aelitis.azureus.core.networkmanager.RawMessage

        int pos = 0;
        boolean stop = false;

        while( !queue.isEmpty() && !stop ) {
          RawMessage msg = (RawMessage)queue.get( 0 );
          DirectByteBuffer[] payloads = msg.getRawData();

          for( int x=0; x < payloads.length; x++ ) {
            ByteBuffer bb = payloads[x].getBuffer( DirectByteBuffer.SS_NET );

            int bytes_written = (bb.limit() - bb.remaining()) - orig_positions[ pos ];
            total_size -= bytes_written;

            if ( msg.getType() == Message.TYPE_DATA_PAYLOAD ){
              total_data_size -= bytes_written;
            }
           
            if( x > 0 && msg.getType() == Message.TYPE_DATA_PAYLOAD ) {  //assumes the first buffer is message header
              data_written += bytes_written;
            }else {
              protocol_written += bytes_written;
            }

            if( bb.hasRemaining() ) {  //still data left to send in this message
              stop = true//so don't bother checking later messages for completion

              //compute send percentage
              int message_size = 0;
              int written = 0;

              for( int i=0; i < payloads.length; i++ ) {
                ByteBuffer buff = payloads[i].getBuffer( DirectByteBuffer.SS_NET );

                message_size += buff.limit();

                if( i < x ) {  //if in front of non-empty buffer
                  written += buff.limit();
                }
                else if( i == x ) {  //is non-empty buffer
                  written += buff.position();
                }
              }

              percent_complete = (written * 100) / message_size;

              break;
            }
            else if( x == payloads.length - 1 ) {  //last payload buffer of message is empty
              if( msg == urgent_message ) urgent_message = null;

              queue.remove( 0 );


              if( TRACE_HISTORY ) {
                prev_sent.addLast( msg );
                if( prev_sent.size() > MAX_HISTORY_TRACES prev_sent.removeFirst();
              }


              percent_complete = -1//reset send percentage

              if( manual_listener_notify ) {
                NotificationItem item = new NotificationItem( NotificationItem.MESSAGE_SENT );
                item.message = msg;
                try delayed_notifications_mon.enter();
                delayed_notifications.add( item );
                } finally delayed_notifications_mon.exit()}
              }
              else {
                if( messages_sent == null ) {
                  messages_sent = new ArrayList();
                }
                messages_sent.add( msg );
              }
            }

            pos++;
            if( pos >= buffer_count ) {
              stop = true;
              break;
            }
          }
        }
      }
    }finally{
      queue_mon.exit();
    }

    // we can have messages that end up getting serialised as 0 bytes (for http
    // connections for example) - we still need to notify them of being sent...

    if( data_written + protocol_written > 0 || messages_sent != null ) {

      if ( trace ){
        TimeFormatter.milliTrace( "omq:deliver: " + (data_written + protocol_written) + ", q=" + queue.size() + "/" + total_size );
      }

      if( manual_listener_notify ) {

        if( data_written > 0 ) {  //data bytes notify
          NotificationItem item = new NotificationItem( NotificationItem.DATA_BYTES_SENT );
          item.byte_count = data_written;
          try {
            delayed_notifications_mon.enter();

            delayed_notifications.add( item );
          }
          finally {
            delayed_notifications_mon.exit();
          }
        }

        if( protocol_written > 0 ) {  //protocol bytes notify
          NotificationItem item = new NotificationItem( NotificationItem.PROTOCOL_BYTES_SENT );
          item.byte_count = protocol_written;
          try {
            delayed_notifications_mon.enter();

            delayed_notifications.add( item );
          }
          finally {
            delayed_notifications_mon.exit();
          }
        }
      }
      else //do listener notification now
        ArrayList listeners_ref = listeners;

        int num_listeners = listeners_ref.size();
        for( int i=0; i < num_listeners; i++ ) {
          MessageQueueListener listener = (MessageQueueListener)listeners_ref.get( i );

          if( data_written > 0 listener.dataBytesSent( data_written );
          if( protocol_written > 0 listener.protocolBytesSent( protocol_written );

          if ( messages_sent != null ){

            for( int x=0; x < messages_sent.size(); x++ ) {
              RawMessage msg = (RawMessage)messages_sent.get( x );

              listener.messageSent( msg.getBaseMessage() );

              if( i == num_listeners - 1 ) {  //the last listener notification, so destroy
                msg.destroy();
              }
            }
          }
        }
      }
View Full Code Here

Examples of com.aelitis.azureus.core.networkmanager.RawMessage

        return;
      }
     
      for (int i=0;i<queue.size();i++){
       
        RawMessage  msg = (RawMessage)queue.get(i);
       
        msg.setNoDelay();
       
        if ( i == 0 ){
         
          urgent_message = msg;
        }
View Full Code Here

Examples of com.aelitis.azureus.core.networkmanager.RawMessage

     
     
      int i=0;
     
      for( Iterator it = prev_sent.iterator(); it.hasNext(); ) {
        RawMessage raw = (RawMessage)it.next();
        trace.append( "[#h" +i+ "]: ")
             .append(raw.getID())
             .append(" [")
             .append(raw.getDescription())
             .append("]")
             .append("\n" );
        i++;
      }     
     
     

      int position = queue.size() - 1;

      for( Iterator it = queue.iterator(); it.hasNext(); ) {
        RawMessage raw = (RawMessage)it.next();
       
        int pos = raw.getRawData()[0].position(DirectByteBuffer.SS_NET);
        int length = raw.getRawData()[0].limit( DirectByteBuffer.SS_NET );
       
        trace.append( "[#")
             .append(position)
             .append(" ")
             .append(pos)
             .append(":")
             .append(length)
             .append("]: ")
             .append(raw.getID())
             .append(" [")
             .append(raw.getDescription())
             .append("]")
             .append("\n" );
       
        position--;
      }
View Full Code Here

Examples of com.amazonaws.services.simpleemail.model.RawMessage

      OutputStream byteOutput = new ByteArrayOutputStream();
      m.writeTo(byteOutput);
      SendRawEmailRequest req = new SendRawEmailRequest();
      byte[] messageByteArray = ((ByteArrayOutputStream) byteOutput)
          .toByteArray();
      RawMessage message = new RawMessage();
      message.setData(ByteBuffer.wrap(messageByteArray));
      req.setRawMessage(message);
      return req;
    } catch (Exception e) {
        Address[] sent = new Address[0];
        Address[] unsent = new Address[0];
View Full Code Here

Examples of com.amazonaws.services.simpleemail.model.RawMessage

      OutputStream byteOutput = new ByteArrayOutputStream();
      m.writeTo(byteOutput);
      SendRawEmailRequest req = new SendRawEmailRequest();
      byte[] messageByteArray = ((ByteArrayOutputStream) byteOutput)
          .toByteArray();
      RawMessage message = new RawMessage();
      message.setData(ByteBuffer.wrap(messageByteArray));
      req.setRawMessage(message);
      return req;
    } catch (Exception e) {
        Address[] sent = new Address[0];
        Address[] unsent = new Address[0];
View Full Code Here

Examples of com.amazonaws.services.simpleemail.model.RawMessage

      OutputStream byteOutput = new ByteArrayOutputStream();
      m.writeTo(byteOutput);
      SendRawEmailRequest req = new SendRawEmailRequest();
      byte[] messageByteArray = ((ByteArrayOutputStream) byteOutput)
          .toByteArray();
      RawMessage message = new RawMessage();
      message.setData(ByteBuffer.wrap(messageByteArray));
      req.setRawMessage(message);
      return req;
    } catch (Exception e) {
        Address[] sent = new Address[0];
        Address[] unsent = new Address[0];
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.