Esempio n. 1
0
  /**
   * Copies both state and data to the supplied packet from this packet by performing a deep copy of
   * the contents of the buffer into packet's internal memory buffer if that buffer is large enough,
   * otherwise a new buffer is allocated. Both packet's state and data are then peered with the
   * internal buffer containing the copy of the supplied buffer
   *
   * @param packet destination packet
   * @return number of bytes copied
   */
  public int transferStateAndDataTo(JMemoryPacket packet) {
    final JBuffer buffer = packet.getMemoryBuffer(this.getTotalSize());

    packet.transferStateAndDataTo(buffer, 0);

    return peerStateAndData(buffer, 0);
  }
Esempio n. 2
0
 /**
  * Copies both state and data from supplied packet to this packet by performing a deep copy of the
  * contents of the buffer into packet's internal memory buffer if that buffer is large enough,
  * otherwise a new buffer is allocated. Both packet's state and data are then peered with the
  * internal buffer containing the copy of the supplied buffer
  *
  * @param packet source packet
  * @return number of bytes copied
  */
 public int transferStateAndDataFrom(JMemoryPacket packet) {
   return packet.transferTo(this);
 }