package com.saki.qq.wtlogin.unpack;

import com.saki.encode.UnPack;

public class Info {
    public int seq;
    public String cmd;
    String version;
    byte[] mark = new byte[]{0x00, 0x00, 0x00, 0x04};
    byte[] token4c = new byte[]{0x00, 0x00, 0x00, 0x4c};

    public Info(byte[] data) {
        UnPack un = new UnPack(data);
        seq = un.getInt();
        int index = un.findBytes(token4c);
        if (index == -1) {
            index = un.findBytes(mark);
            un.getBytes(index + 4);
        } else {
            un.getBytes(index + 0x4c);
        }
        int len = un.getInt();
        cmd = new String(un.getBytes(len - 4));
        index = un.findBytes(mark);
        if (index != -1) {
            un.getBytes(index + 4);
            len = un.getShort();
            version = new String(un.getBytes(len - 2));
        }
    }

    @Override
    public String toString() {
        return "SEQ:" + seq + "\r\nCMD:" + cmd + "\r\nVER:" + version;
    }
}
