Package java.nio

Examples of java.nio.ByteBuffer.capacity()


    try {
      ByteBuffer decompressedData = JMuleZLib.decompressData(compressedData);
      decompressedData.position(0);
     
      byte packetOPCode = packet_data.get(1);
      packet_data = getByteBuffer(decompressedData.capacity()+2);

      packet_data.put(PROTO_KAD_UDP);
      packet_data.put(packetOPCode);
      packet_data.put(decompressedData);
     
View Full Code Here


          try {
            buffer = JMuleZLib
                .decompressData(container.compressedData);
            buffer.position(0);
            FileChunk chunk = new FileChunk(container.offset,
                container.offset + buffer.capacity(), buffer);
            processFileChunk(sender, chunk);
            chunk_list.remove(container);
          } catch (DataFormatException e) {
            e.printStackTrace();
          }
View Full Code Here

        ByteBuffer buffer;
        try {
          buffer = JMuleZLib.decompressData(container.compressedData);
          buffer.position(0);
          FileChunk chunk = new FileChunk(container.offset,
              container.offset + buffer.capacity(), buffer);
          processFileChunk(sender, chunk);
          chunk_list.remove(container);
        } catch (DataFormatException e) {

          e.printStackTrace();
View Full Code Here

    try {
      switch (packet_protocol) {
      case PROTO_EDONKEY_SERVER_UDP: {
        switch (packet_op_code) {
        case OP_GLOBSERVSTATUS: {
          if (packet_content.capacity() < 15) {
            int challenge = packet_content.getInt();
            long user_count = Convert.intToLong(packet_content
                .getInt());
            long files_count = Convert.intToLong(packet_content
                .getInt());
View Full Code Here

  public static KadPacket getPublishReqPacket(Int128 targetID,
      ClientID clientID, TagList tagList) {
    ByteBuffer tags = tagsToByteBuffer(tagList);

    KadPacket packet = new KadPacket(KADEMLIA_PUBLISH_REQ, 16 + 2 + 16 + 2
        + tags.capacity());
    packet.insertData(targetID.toByteArray());
    packet.insertData((short) 1);
    packet.insertData(clientID.toByteArray());
    packet.insertData(intToByte(tagList.size()));
    tags.position(0);
View Full Code Here

    List<ByteBuffer> tag_list = new LinkedList<ByteBuffer>();
    int tags_size = 0;
    if (sourceList != null)
      for (Source source : sourceList) {
        ByteBuffer tmp = tagsToByteBuffer(source.getTagList());
        tags_size += tmp.capacity();
        tmp.position(0);
        tag_list.add(tmp);
      }

    int sourceCount = 0;
View Full Code Here

    List<ByteBuffer> tag_list = new LinkedList<ByteBuffer>();
    int tags_size = 0;
    if (contactList != null)
      for (Source source : contactList) {
        ByteBuffer tmp = tagsToByteBuffer(source.getTagList());
        tags_size += tmp.capacity();
        tmp.position(0);
        tag_list.add(tmp);
      }

    int contactCount = 0;
View Full Code Here

      ClientID publisherID, TagList tagList) {
    ByteBuffer tag_list = tagsToByteBuffer(tagList);
    tag_list.position(0);

    KadPacket packet = new KadPacket(KADEMLIA_PUBLISH_NOTES_REQ,
        16 + 16 + 2 + tag_list.capacity());

    packet.insertData(noteID.toByteArray());
    packet.insertData(publisherID.toByteArray());
    packet.insertData(intToByte(tagList.size()));
    packet.insertData(tag_list);
View Full Code Here

  public static KadPacket getHello2ReqPacket(TagList tagList)
      throws JMException {
    ByteBuffer tags = tagsToByteBuffer(tagList);

    KadPacket packet = new KadPacket(KADEMLIA2_HELLO_REQ, 16 + 2 + 1 + 1
        + tags.capacity());

    packet.insertData(JKadManagerSingleton.getInstance().getClientID()
        .toByteArray());

    ConfigurationManager configManager = ConfigurationManagerSingleton
View Full Code Here

  public static KadPacket getHello2ResPacket(TagList tagList)
      throws JMException {
    ByteBuffer tag_list = tagsToByteBuffer(tagList);
    KadPacket packet = new KadPacket(KADEMLIA2_HELLO_RES, 16 + 2 + 1 + 1
        + tag_list.capacity());
    packet.insertData(JKadManagerSingleton.getInstance().getClientID()
        .toByteArray());
    ConfigurationManager configManager = ConfigurationManagerSingleton
        .getInstance();
    packet.insertData(intToShort(configManager.getTCP()));
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.