Fast msgpack implementation written in javascript and made specifically for moomoo.
Prone to most common packets used for lagging or crashing servers that use msgpack-lite.
Try it at https://0xffabc.github.io/MsgpackP/msgpackp-example.html
Head over to https://0xffabc.github.io/MsgpackP/codec.js to see a build of this script. Copypaste it in your website and modify it as in next patches for your needs;
- let msgpack = {
+ window.msgpack = {
- let msgpack = {
+ module.exports = {
+ export default msgpack
Synchronously packs data with msgpack format (not recommended)
const packet = msgpack._encode({
thing: 5.88283882919
});
socket.send(packet);
Synchronously unpacks data with msgpack format (not recommended)
socket.on("message", ({ data }) => {
console.log(msgpack._decode(data));
});
Packs the data with msgpack format. Recommended for most of cases, since it's easier to control exceptions that happen while packing data.
const socket = new WebSocketStream("wss://127.0.0.1");
const { readable, writable, extensions, protocol } = await wss.opened;
const writer = writable.getWriter();
msgpack.pack("hello").then(raw =>
writer.write(raw)).catch(console.log);
Unpacks the data with msgpack format. Recommended for most of cases, since it's easier to control exceptions that happen while packing data.
const socketWorker = new Worker("ws.js");
socketWorker.onmessage = async ({ data }) => {
const [ packetSid, packetData ] = await msgpack.unpack(data);
console.log(packetSid, packetData);
}
socketWorker.postMessage("ready");
Completely unsupported types: timestamp, bin, ext, float32
If you have found any issue, report it in issues tab