focus election, issue #34
This commit is contained in:
parent
2f7b21588c
commit
53f97c6c29
10
app.js
10
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)]);
|
||||
}
|
||||
|
|
4
muc.js
4
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;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue