Skip to content

NuroC/msgpacklib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

a msgpack implementation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •