Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

focus election, issue #34

Philipp Hancke53f97c6c29ad
diff --git a/app.js b/app.js
index 7167a359bb..79a99f5545 100644
--- a/app.js
+++ b/app.js
@@ -322,7 +322,14 @@ $(document).bind('left.muc', function (event, jid) {
resizeThumbnails();
}
- if (Object.keys(connection.emuc.members).length === 0) {
+ if (focus === null && connection.emuc.myroomjid == connection.emuc.list_members[0]) {
+ console.log('welcome to our new focus... myself');
+ focus = new ColibriFocus(connection, config.hosts.bridge);
+ if (Object.keys(connection.emuc.members).length > 0) {
+ focus.makeConference(Object.keys(connection.emuc.members));
+ }
+ }
+ else if (focus && Object.keys(connection.emuc.members).length === 0) {
console.log('everyone left');
if (focus !== null) {
// FIXME: closing the connection is a hack to avoid some
@@ -333,7 +340,6 @@ $(document).bind('left.muc', function (event, jid) {
focus = new ColibriFocus(connection, config.hosts.bridge);
}
}
-
if (connection.emuc.getPrezi(jid)) {
$(document).trigger('presentationremoved.muc', [jid, connection.emuc.getPrezi(jid)]);
}
diff --git a/muc.js b/muc.js
index aacfdc9ef1..5e3feccfb4 100644
--- a/muc.js
+++ b/muc.js
@@ -7,6 +7,7 @@ Strophe.addConnectionPlugin('emuc', {
roomjid: null,
myroomjid: null,
members: {},
+ list_members: [], // so we can elect a new focus
presMap: {},
preziMap: {},
joined: false,
@@ -87,10 +88,12 @@ Strophe.addConnectionPlugin('emuc', {
if (!this.joined) {
this.joined = true;
$(document).trigger('joined.muc', [from, member]);
+ this.list_members.push(from);
}
} else if (this.members[from] === undefined) {
// new participant
this.members[from] = member;
+ this.list_members.push(from);
$(document).trigger('entered.muc', [from, member, pres]);
} else {
console.log('presence change from', from);
@@ -101,6 +104,7 @@ Strophe.addConnectionPlugin('emuc', {
onPresenceUnavailable: function (pres) {
var from = pres.getAttribute('from');
delete this.members[from];
+ this.list_members.splice(this.list_members.indexOf(from), 1);
$(document).trigger('left.muc', [from]);
return true;
},