Using libmisbcore with Nodejs
To use the libmisbcore library with Node.js, you can either write an add-on or use an npm library such as ffi-napi.
Using libmisbcore with ffi-napi
Note: you must add the ffi-napi package.
Here is a code that prints a nodeinfo string, reads a raw binary buffer and decodes it to JSON:
import ffi from 'ffi-napi';
import fs from 'fs';
const binaryBuf = fs.readFileSync('./packet.bin');
const libmCore = ffi.Library('./libmisbcore.dll', {
'GetNodeInfo': [ 'string', [ ] ],
'Decode': ['string', ['pointer', 'int']],
});
console.log(libmCore.GetNodeInfo());
const jsonPckt = libmCore.Decode(binaryBuf, binaryBuf.length);
console.log(jsonPckt);