msgpacklib

a msgpack implementation

Skrip ini tidak untuk dipasang secara langsung. Ini adalah pustaka skrip lain untuk disertakan dengan direktif meta // @require https://update.greasyfork.org/scripts/450632/1088933/msgpacklib.js

Penulis
Nuro#9818
Versi
0.0.1.20220902185359
Dibuat
02 September 2022
Diperbarui
02 September 2022
Lisensi
N/A
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