js代码为:
const obj = tap.create();
quote.on("connection", (params) => {
console.log('[DEBUG js]', 'connection called, params:', params);
});记住c++中的函数:
napi_create_reference(env, args[1], 1, &cbMap[eIt->second]);当调用本机函数时:
void TAP_CDECL Spi::OnConnect(int errorCode, const Info *info) {
{{I want to call the function from cbMap here, How to write code? I do not
known how to find "env"!}}
}发布于 2017-08-03 08:44:24
我用node-addon-api解决了这个问题,现在我发现napi更新了,来自https://insight.io/github.com/nodejs/node/tree/master/test/addons-napi/test_env_sharing/,我觉得很有用!
https://stackoverflow.com/questions/45004625
复制相似问题