From d0b9b96675885950270eac324159c03fd9971ba3 Mon Sep 17 00:00:00 2001 From: plutoless Date: Mon, 26 Nov 2018 19:11:22 +0800 Subject: [PATCH] fix few issues --- .../record/AgoraRecordSdk.js | 5 ++++- .../src/agora_node_ext/agora_node_recording.cpp | 11 +++++++++-- .../server/recordManager.js | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Agora-Restful-Recording-Nodejs/record/AgoraRecordSdk.js b/Agora-Restful-Recording-Nodejs/record/AgoraRecordSdk.js index cd1fba2..095aa34 100644 --- a/Agora-Restful-Recording-Nodejs/record/AgoraRecordSdk.js +++ b/Agora-Restful-Recording-Nodejs/record/AgoraRecordSdk.js @@ -25,6 +25,9 @@ class AgoraRecordSdk extends EventEmitter { this.onEvent("error", (err, stat) => { fire('error', err, stat); }); + this.onEvent("userjoin", (err, stat) => { + fire('userjoin', err, stat); + }); this.onEvent("userleave", (err, stat) => { fire('userleave', err, stat); }); @@ -42,7 +45,7 @@ class AgoraRecordSdk extends EventEmitter { }; const cfgPath = path.join(storeFolder, '/cfg.json') fs.writeFile(cfgPath, JSON.stringify(json), err => { - this.recording.joinChannel(key, name, binPath, appid, uid, cfgPath); + this.recording.joinChannel(key || null, name, binPath, appid, uid, cfgPath); this.once("error", err => { reject(err); }) diff --git a/Agora-Restful-Recording-Nodejs/record/src/agora_node_ext/agora_node_recording.cpp b/Agora-Restful-Recording-Nodejs/record/src/agora_node_ext/agora_node_recording.cpp index 25a10b0..d487789 100755 --- a/Agora-Restful-Recording-Nodejs/record/src/agora_node_ext/agora_node_recording.cpp +++ b/Agora-Restful-Recording-Nodejs/record/src/agora_node_ext/agora_node_recording.cpp @@ -109,10 +109,17 @@ namespace agora { status = napi_get_value_nodestring_(args[5], cfgPath); CHECK_NAPI_STATUS(status); string str_appid = (string)appid; - string str_key = ""; string str_name = (string)name; string str_appliteDir = (string)applitDir; string str_cfgPath = (string)cfgPath; + string str_key; + + if(key == nullptr) { + str_key = ""; + } else { + str_key = (string)key; + } + config.appliteDir = const_cast(str_appliteDir.c_str()); config.cfgFilePath = const_cast(str_cfgPath.c_str()); config.isMixingEnabled = true; @@ -146,7 +153,7 @@ namespace agora { //todo // pRecording->m_agorasdk->updateMixModeSetting(0, 0, true); - int result = pRecording->m_agorasdk->createChannel(str_appid, "", str_name, uid, config); + int result = pRecording->m_agorasdk->createChannel(str_appid, str_key, str_name, uid, config); cout << "pRecording->m_agorasdk->createChannel return result:" << result << endl; napi_set_int_result(args, result); } while(false); diff --git a/Agora-Restful-Recording-Nodejs/server/recordManager.js b/Agora-Restful-Recording-Nodejs/server/recordManager.js index 15f6e06..3b78ac8 100644 --- a/Agora-Restful-Recording-Nodejs/server/recordManager.js +++ b/Agora-Restful-Recording-Nodejs/server/recordManager.js @@ -72,14 +72,24 @@ class RecordManager{ delete this.recorders[`${sid}`]; }); sdk.on("userleave", (uid) => { + console.log(`user leave ${uid}`); //rearrange layout when user leaves - sdk.layout.regions = sdk.layout.regions.filter((region) => { + + let recorder = this.find(sid); + + if(!recorder) { + console.error("no reocrder found"); + return; + } + let {layout} = recorder; + layout.regions = layout.regions.filter((region) => { return region.uid !== uid }) - sdk.setMixLayout(sdk.layout); + sdk.setMixLayout(layout); }); sdk.on("userjoin", (uid) => { //rearrange layout when new user joins + console.log(`user join ${uid}`); let region = { "x": 0, "y": 0,