Skip to content

Commit

Permalink
Merge pull request #1 from surebeli/feat/3.9.0/context-aware
Browse files Browse the repository at this point in the history
3.9.0-rc-902:
  • Loading branch information
surebeli authored Apr 23, 2021
2 parents 5b835b4 + 62c20e6 commit 9dd9346
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# node-nertc-sdk

3.9.0-rc-901
3.9.0-rc-902

based on 网易云信 https://netease.im/
17 changes: 9 additions & 8 deletions just-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ const download = require('./scripts/download')
const cleanup = require('./scripts/cleanup')
const extract = require('./scripts/extract')

option('electron_version', {default: '8.1.1'});
option('runtime', {default: 'electron', choices: ['electron', 'node']});
option('platform', {default: process.platform, choices: ['darwin', 'win32']});
option('debug', {default: false, boolean: true});
option('silent', {default: false, boolean: true});
option('msvs_version', {default: '2015'});
let electron_version = '8.5.5'
let sdk_url = `http://yx-web.nos.netease.com/package/${process.platform}-sdk.zip`
const projectDir = path.join(process.env.INIT_CWD, 'package.json')
const pkgMeta = require(projectDir);
if (pkgMeta.nertc_config) {
electron_version = pkg.pkgMeta.nertc_config.electron_version
}

// trigger when run npm install
task('install', () => {
return new Promise((resolve, reject) => {
cleanup(path.join(__dirname, "./build")).then(() => {
cleanup(path.join(__dirname, "./nertc_sdk")).then(() => {
download(`http://yx-web.nos.netease.com/package/${process.platform}-sdk.zip`, "../").then(f => {
download(sdk_url, "../").then(f => {
extract(f, "../").then(() => {
build({})
build({electronVersion: electron_version})
resolve()
})
})
Expand Down
9 changes: 6 additions & 3 deletions nertc_sdk_node/nertc_node_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ NertcNodeEngine::~NertcNodeEngine()
rtc_engine_ = nullptr;
}
}
void NertcNodeEngine::InitModule(Local<Object> &module)
// void NertcNodeEngine::InitModule(Local<Object> &module)
void NertcNodeEngine::InitModule(Local<Object> &exports,
Local<Value> &module,
Local<Context> &context)
{
BEGIN_OBJECT_INIT(NertcNodeEngine, New, 5)
BEGIN_OBJECT_INIT_EX(NertcNodeEngine, New, 5)
SET_PROTOTYPE(initialize)
SET_PROTOTYPE(release)
SET_PROTOTYPE(setChannelProfile)
Expand Down Expand Up @@ -128,7 +131,7 @@ void NertcNodeEngine::InitModule(Local<Object> &module)
SET_PROTOTYPE(setDevice)
SET_PROTOTYPE(getDevice)

END_OBJECT_INIT(NertcNodeEngine)
END_OBJECT_INIT_EX(NertcNodeEngine)
}

void NertcNodeEngine::New(const FunctionCallbackInfo<Value> &args)
Expand Down
5 changes: 4 additions & 1 deletion nertc_sdk_node/nertc_node_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ class NertcNodeEngine : public node::ObjectWrap
/* data */
public:
static void New(const FunctionCallbackInfo<Value> &args);
static void InitModule(Local<Object> &module);
// static void InitModule(Local<Object> &module);
static void InitModule(Local<Object> &exports,
Local<Value> &module,
Local<Context> &context);

public:
NIM_SDK_NODE_API(initialize);
Expand Down
14 changes: 10 additions & 4 deletions nertc_sdk_node/nertc_node_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
#include "nertc_node_engine.h"
using v8::Object;

void InitNertc(Local<Object> module)
{
nertc_node::NertcNodeEngine::InitModule(module);
// void InitNertc(Local<Object> module)
// {
// nertc_node::NertcNodeEngine::InitModule(module);
// }
void InitNertc(Local<Object> exports,
Local<Value> module,
Local<Context> context) {
nertc_node::NertcNodeEngine::InitModule(exports, module, context);
}

NODE_MODULE(nertc, InitNertc)
NODE_MODULE_CONTEXT_AWARE(nertc, InitNertc)

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nertc-sdk",
"version": "3.9.0-rc-901",
"version": "3.9.0-rc-902",
"description": "node-nertc-sdk",
"main": "js/nertc_sdk.js",
"types": "types/nertc_sdk.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = ({
arch = 'ia32',
distUrl = 'https://electronjs.org/headers'
}) => {
logger.info('start building...');
logger.info(`start building...${runtime}-${electronVersion}`);

/** get command string */
const command = [`${gyp_exec} configure`];
Expand Down
11 changes: 11 additions & 0 deletions shared/sdk_helper/nim_node_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ TypeName& operator=(const TypeName&) = delete
constructor.Reset(isolate, tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); \
module->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, #className, v8::NewStringType::kNormal).ToLocalChecked(), tpl->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());

#define BEGIN_OBJECT_INIT_EX(className, constructor, fieldCount) \
Isolate* isolate = context->GetIsolate(); \
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, constructor); \
tpl->SetClassName(String::NewFromUtf8(isolate, #className, v8::NewStringType::kNormal).ToLocalChecked()); \
tpl->InstanceTemplate()->SetInternalFieldCount(fieldCount);

#define END_OBJECT_INIT_EX(className) \
constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked()); \
exports->Set(context, String::NewFromUtf8(isolate, #className, v8::NewStringType::kNormal).ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked());


#define NIM_SDK_NODE_API(m) \
static void(m)(const FunctionCallbackInfo<Value> &args)

Expand Down

0 comments on commit 9dd9346

Please sign in to comment.