Package java.nio

Examples of java.nio.ByteBuffer.array()


      Packet packet = new Packet(4+data_length, PROTO_EDONKEY_TCP);
      packet.setCommand(OP_OFFERFILES);
      packet.insertData(sharedFiles.size());
     
      for(ByteBuffer buffer : shared_files_data)
        packet.insertData(buffer.array());
     
      return packet;
    }
   
   // =======================
View Full Code Here


          packet_data.get(file_hash);
          long chunk_start = Convert.intToLong(packet_data.getInt());
          long chunk_end = Convert.intToLong(packet_data.getInt());
          ByteBuffer chunk_content = Misc.getByteBuffer(chunk_end
              - chunk_start);
          packet_data.get(chunk_content.array());
          _network_manager.receivedRequestedFileChunkFromPeer(peerIP,
              peerPort, new FileHash(file_hash), new FileChunk(
                  chunk_start, chunk_end, chunk_content));

          break;
View Full Code Here

          byte[] file_hash = new byte[16];
          packet_data.get(file_hash);
          int name_length = Convert
              .shortToInt(packet_data.getShort());
          ByteBuffer str_bytes = Misc.getByteBuffer(name_length);
          packet_data.get(str_bytes.array());
          _network_manager.receivedFileRequestAnswerFromPeer(peerIP,
              peerPort, new FileHash(file_hash), new String(
                  str_bytes.array()));
          break;
        }
View Full Code Here

              .shortToInt(packet_data.getShort());
          ByteBuffer str_bytes = Misc.getByteBuffer(name_length);
          packet_data.get(str_bytes.array());
          _network_manager.receivedFileRequestAnswerFromPeer(peerIP,
              peerPort, new FileHash(file_hash), new String(
                  str_bytes.array()));
          break;
        }

        case OP_FILEREQANSNOFILE: {
          byte[] file_hash = new byte[16];
View Full Code Here

        case OP_MESSAGE: {
          int message_length = Convert.shortToInt(packet_data
              .getShort());
          ByteBuffer message_bytes = Misc
              .getByteBuffer(message_length);
          packet_data.get(message_bytes.array());
          String message = new String(message_bytes.array());
          message_bytes.clear();
          message_bytes = null;
          _peer_manager.receivedMessage(peerIP, peerPort, message);
          break;
View Full Code Here

     
      for(FileChunkRequest request : partsData) {
        num.clear();
        num.rewind();
        num.putInt(Convert.longToInt(request.getChunkBegin()));
        packet.insertData(num.array());
      }
     
      for(FileChunkRequest request : partsData) {
        num.clear();
        num.rewind();
View Full Code Here

          int message_length = Convert.shortToInt(packet_data
              .getShort());
          ByteBuffer message_bytes = Misc
              .getByteBuffer(message_length);
          packet_data.get(message_bytes.array());
          String message = new String(message_bytes.array());
          message_bytes.clear();
          message_bytes = null;
          _peer_manager.receivedMessage(peerIP, peerPort, message);
          break;
        }
View Full Code Here

          long chunkStart = Convert.intToLong(packet_data.getInt());
          long chunkEnd = Convert.intToLong(packet_data.getInt());
          long compressedSize = packet_data.capacity()
              - packet_data.position();
          ByteBuffer data = Misc.getByteBuffer(compressedSize);
          packet_data.get(data.array());

          _network_manager.receivedCompressedFileChunkFromPeer(
              peerIP, peerPort, new FileHash(file_hash),
              new FileChunk(chunkStart, chunkEnd, data));
          break;
View Full Code Here

        case OP_CHATCAPTCHAREQ: {
          packet_data.get();

          ByteBuffer image_data = Misc.getByteBuffer(pkLength - 2);
          image_data.position(0);
          packet_data.get(image_data.array());
          image_data.position(0);
          _peer_manager.receivedCaptchaImage(peerIP, peerPort,
              image_data);
          break;
        }
View Full Code Here

     
      for(FileChunkRequest request : partsData) {
        num.clear();
        num.rewind();
        num.putInt(Convert.longToInt(request.getChunkEnd()));
        packet.insertData(num.array());
      }
     
      return packet;
  }
 
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.