Example #1
0
  /**
   * Generates a new set-ICBM-parameter-information command from the given incoming SNAC packet.
   *
   * @param packet an incoming set-ICBM-parameters packet
   */
  protected SetParamInfoCmd(SnacPacket packet) {
    super(CMD_SET_PARAM_INFO);

    DefensiveTools.checkNull(packet, "packet");

    ByteBlock snacData = packet.getData();

    paramInfo = ParamInfo.readParamInfo(snacData);
  }
Example #2
0
  /**
   * Generates a new item-based command from the given incoming SNAC packet.
   *
   * @param command the SNAC command subtype for this command
   * @param packet an incoming item-based command packet
   */
  protected ItemsCmd(int command, SnacPacket packet) {
    super(command);

    DefensiveTools.checkNull(packet, "packet");

    ByteBlock block = packet.getData();

    List<SsiItem> itemList = new ArrayList<SsiItem>();

    for (; ; ) {
      SsiItem item = SsiItem.readSsiItem(block);
      if (item == null) break;

      itemList.add(item);

      block = block.subBlock(item.getTotalSize());
    }

    items = DefensiveTools.getUnmodifiable(itemList);
  }
  /**
   * 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;
    }
  }