2

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"!}}

}
4

1 回答 1

0

我用node-addon-api解决了这个问题,现在我发现napi更新了,从https://insight.io/github.com/nodejs/node/tree/master/test/addons-napi/test_env_sharing/,我觉得很有用!

于 2017-08-03T00:44:24.390 回答