Ejemplo n.º 1
0
  public void writeData(OutputStream out) throws IOException {
    BinaryTools.writeUShort(out, family);

    if (roomInfo != null) {
      ByteBlock roomInfoBlock = ByteBlock.createByteBlock(roomInfo);
      new Tlv(TYPE_ROOM_INFO, roomInfoBlock).write(out);
    }
  }
Ejemplo n.º 2
0
  /**
   * Generates a new service request command from the given incoming SNAC packet.
   *
   * @param packet the incoming service request packet
   */
  protected ServiceRequest(SnacPacket packet) {
    super(CMD_SERVICE_REQ);

    DefensiveTools.checkNull(packet, "packet");

    ByteBlock snacData = packet.getData();

    family = BinaryTools.getUShort(snacData, 0);

    ByteBlock tlvBlock = snacData.subBlock(2);

    TlvChain chatChain = TlvTools.readChain(tlvBlock);

    Tlv chatInfoTlv = chatChain.getLastTlv(TYPE_ROOM_INFO);

    if (chatInfoTlv != null) {
      ByteBlock chatBlock = chatInfoTlv.getData();

      roomInfo = MiniRoomInfo.readMiniRoomInfo(chatBlock);
    } else {
      roomInfo = null;
    }
  }