altmp / altv-js-module

JS module for alt:V Multiplayer. Powered by NodeJS & v8
MIT License
54 stars 36 forks source link

fix array buffer (de)serialization #322

Closed xxshady closed 1 month ago

xxshady commented 1 month ago

Fixes conflict of directly sending byte array mvalue and raw emit (which uses byte array mvalue under the hood) by changing order of header and magic bytes

import alt from 'alt-server'

alt.on('test', (data) => {
  alt.log({ data })
})

// fails at deserialization
// [Error] [V8] Exception: Error: Unable to deserialize cloned data due to invalid or unsupported version.
alt.emit('test', new Uint8Array([1, 2, 3, 4, 5]).buffer)
// works
alt.emitRaw('test', [1, 2, 3])