Skip to content

Commit

Permalink
fix few issues
Browse files Browse the repository at this point in the history
  • Loading branch information
plutoless committed Nov 26, 2018
1 parent 48ac989 commit d0b9b96
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Agora-Restful-Recording-Nodejs/record/AgoraRecordSdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(str_appliteDir.c_str());
config.cfgFilePath = const_cast<char*>(str_cfgPath.c_str());
config.isMixingEnabled = true;
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions Agora-Restful-Recording-Nodejs/server/recordManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d0b9b96

Please sign in to comment.