const struct = require('./jspack/jspack')

function unpackPacket(packet) {
    // let buffer = new Array(1024)
    let chain_id = null; exec_id = null, function_count = null, function_id = null
    let base = 0
    chain_id = struct.Unpack(">I", packet, base)
    base += 4
    exec_id = struct.Unpack(">I", packet, base)
    base += 4
    function_id = struct.Unpack("B", packet, base)
    base += 1
    data = struct.Unpack(">I", packet, base)
    base += 4
    function_count = struct.Unpack("B", packet, base)

    console.log("chain_id", chain_id, "exec_id", exec_id, "data", data, "function_count", function_count, "function_id", function_id)
}