示例#1
0
 /** overrides encode in HooMEMessage */
 @Override
 public void encode(MessageOutput out) throws java.io.IOException {
   super.encode(out);
   out.getDataOutputStream().writeShort((short) (this.searchString.length() + 1));
   out.getDataOutputStream().write(this.searchString.getBytes(HooMEMessage.CHARENCODING));
   out.getDataOutputStream().write(Consts.EOLN.getBytes(HooMEMessage.CHARENCODING));
 }
示例#2
0
  /** overides encode in HooMEMessage */
  @Override
  public void encode(MessageOutput out) throws java.io.IOException {
    super.encode(out);
    int payLoadLength = 0;
    for (Result aResult : this.resultList) {
      payLoadLength += aResult.getFileName().length() + 1;
    }
    // add header for result
    payLoadLength += (Consts.FOUR_BITS + Consts.FOUR_BITS) * this.resultList.size();
    // add the header for response
    payLoadLength += 1 + Consts.TWO_BITS + Consts.FOUR_BITS;

    out.getDataOutputStream().writeShort((short) payLoadLength);
    out.getDataOutputStream().writeByte((byte) this.resultList.size());
    out.getDataOutputStream().writeShort((short) this.responseHost.getPort());
    out.getDataOutputStream().write(this.responseHost.getAddress().getAddress());
    for (Result aResult : this.resultList) {
      aResult.encode(out);
    }
  }