msgpacklib

a msgpack implementation

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/450632/1088933/msgpacklib.js

作者
Nuro#9818
版本
0.0.1.20220902185359
建立日期
2022-09-02
更新日期
2022-09-02
尺寸
3.3 KB
授權條款
未知
const Writer = msgpacklib.writer;
const Reader = msgpacklib.reader;

receive packets:

onmessage = function (e) {
    let data = e.data;
    let packet = new Reader(data);
    let [packetID, info] = packet.readData();
}

send packets:

 function send(packetID, ...args) {
    let binData = new Writer(1, args).setString(packetID).setInt(144 + args.length, !0);
    args && args.forEach(e => {
        switch (typeof e) {
            case 'number':
                Number.isSafeInteger(e) ? binData.setInt(e) : binData.setFloat(e);
                break;
            case 'string':
                binData.setString(e);
        }
    });
    let packet = binData.arraybuffer;
    socket.send(packet);
    return packet;
}

made for moomoo.io so idk if u wanna use it in other stuff

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址