package com.yutou.biliapi.bean.websocket;

import com.yutou.biliapi.utils.BytesUtils;
import lombok.Data;

@Data
public class WebSocketHeader {
    int dataSize;
    int agree;
    int headerSize;
    int cmdData;

    public WebSocketHeader(byte[] bytes) {
        byte[] size = new byte[4];
        byte[] header = new byte[4];
        byte[] cmd = new byte[4];
        byte[] agreement = new byte[4];
        System.arraycopy(bytes, 0, size, 0, 4);
        System.arraycopy(bytes, 8, cmd, 0, 4);
        System.arraycopy(bytes, 6, agreement, 2, 2);
        System.arraycopy(bytes, 4, header, 2, 2);
        dataSize = BytesUtils.bytesToInt2(size, 0);
        agree = BytesUtils.bytesToInt2(agreement, 0);
        headerSize = BytesUtils.bytesToInt2(header, 0);
        cmdData = BytesUtils.bytesToInt2(cmd, 0);
    }
}
