Commit 3fd2e9f5 authored by Yoann HOUPERT's avatar Yoann HOUPERT
Browse files

add robot disconnect feature

parent 561abb94
......@@ -53,6 +53,10 @@ robotController = {
});
},
disconnect: () => {
angular.element(document.getElementsByClassName('conference-user-control-bar')[0].childNodes[0].childNodes[2].childNodes[0]).scope().leaveConference();
},
onAttendeePush: () => {},
onAttendeeRemove: () => {},
onAttendeeUpdate: () => {}
......
......@@ -83,11 +83,36 @@ robot = {
robot.getUserStream(easyrtcid);
},
getParticipantNumber() {
const participants = robotController.getParticipants();
let participantsNumber = participants.length;
for (let i = 0; i < participants.length; i++) {
const participant = participants[i];
try {
const mediaStream = robotController.getRemoteStream(participant);
if (mediaStream === null) {
participantsNumber--;
}
} catch (err) {
console.error('could not get remote stream for %s', participant);
console.error(err);
}
}
return participantsNumber;
},
stopRecordParticipant(easyrtcid) {
robot.participantsMediaRecorders[easyrtcid].stop();
robot.recordedParticipantsWS[easyrtcid].close();
},
disconnectRobot() {
if (robot.getParticipantNumber() === 1) {
robotController.disconnect();
}
},
start: () => {
robotLib.stt = robotLib.stt(config);
robotLib.reco = robotLib.reco(config);
......@@ -99,6 +124,7 @@ robot = {
robotController.onAttendeeRemove = (e, data) => {
robot.stopRecordParticipant(data.easyrtcid);
robot.disconnectRobot();
};
function recoStartRetry() {
......@@ -122,6 +148,9 @@ robot = {
robot.recordParticipant(participantId);
}
}
// Wait 5 minute before leaving a room if alone
setTimeout(robot.disconnectRobot(), 300000);
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment