Ejemplo n.º 1
0
  /**
   * Debug Helper!!!!
   *
   * <p>I'm leaving this message here without any callers for a reason: During debugs it's important
   * eventually to identify what's on the bodies, and this method will give you a good idea about
   * them. Add the message.bodyToString() to the Watch variables on the debugger view and this will
   * show up like a charm!!!
   *
   * @return
   */
  public String bodyToString() {
    getEndOfBodyPosition();
    int readerIndex1 = this.buffer.readerIndex();
    buffer.readerIndex(0);
    byte[] buffer1 = new byte[buffer.writerIndex()];
    buffer.readBytes(buffer1);
    buffer.readerIndex(readerIndex1);

    byte[] buffer2 = null;
    if (bodyBuffer != null) {
      int readerIndex2 = this.bodyBuffer.readerIndex();
      bodyBuffer.readerIndex(0);
      buffer2 = new byte[bodyBuffer.writerIndex() - bodyBuffer.readerIndex()];
      bodyBuffer.readBytes(buffer2);
      bodyBuffer.readerIndex(readerIndex2);
    }

    return "ServerMessage@"
        + Integer.toHexString(System.identityHashCode(this))
        + "["
        + ",bodyStart="
        + getEndOfBodyPosition()
        + " buffer="
        + ByteUtil.bytesToHex(buffer1, 1)
        + ", bodyBuffer="
        + ByteUtil.bytesToHex(buffer2, 1);
  }
Ejemplo n.º 2
0
  private void forceCopy() {
    // Must copy buffer before sending it

    buffer = buffer.copy(0, buffer.capacity());

    buffer.setIndex(0, getEndOfBodyPosition());

    if (bodyBuffer != null) {
      bodyBuffer.setBuffer(buffer);
    }

    bufferUsed = false;
  }