Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix: Handles disconnect coming from jicofo to destroy visitor rooms.
damencho07af18e2847b
diff --git a/resources/prosody-plugins/mod_fmuc.lua b/resources/prosody-plugins/mod_fmuc.luaindex 48fbfe650c..499dde6422 100644--- a/resources/prosody-plugins/mod_fmuc.lua+++ b/resources/prosody-plugins/mod_fmuc.lua@@ -138,12 +138,6 @@ module:hook('muc-occupant-left', function (event)-- if there are no visitors give them 15 secs to reconnect, if not destroy itlocal main_count, visitors_count = get_occupant_counts(room);- if main_count == 0 then- module:log('info', 'Will destroy:%s main_occupants:%s visitors:%s', room.jid, main_count, visitors_count);- room:destroy(nil, 'No main participants.');- return;- end-if visitors_count == 0 thenschedule_destroy_timer(room);end@@ -409,12 +403,18 @@ local function iq_from_main_handler(event)local node = visitors_iq:get_child('connect');local fire_jicofo_unlock = true;+ local process_disconnect = false;if not node thennode = visitors_iq:get_child('update');fire_jicofo_unlock = false;end+ if not node then+ node = visitors_iq:get_child('disconnect');+ process_disconnect = true;+ end+if not node thenreturn;end@@ -427,6 +427,13 @@ local function iq_from_main_handler(event)id = stanza.attr.id}));+ if process_disconnect then+ local main_count, visitors_count = get_occupant_counts(room);+ module:log('info', 'Will destroy:%s main_occupants:%s visitors:%s', room.jid, main_count, visitors_count);+ room:destroy(nil, 'Conference ended.');+ return true;+ end+-- if there is password supplied use it-- if this is update it will either set or remove the passwordroom:set_password(node.attr.password);diff --git a/resources/prosody-plugins/mod_visitors.lua b/resources/prosody-plugins/mod_visitors.luaindex ed2046c47c..5ac7dc4ec3 100644--- a/resources/prosody-plugins/mod_visitors.lua+++ b/resources/prosody-plugins/mod_visitors.lua@@ -63,7 +63,9 @@ local function send_visitors_iq(conference_service, room, type)id = iq_id }):tag('visitors', { xmlns = 'jitsi:visitors',room = jid.join(jid.node(room.jid), conference_service) })- :tag(type, { xmlns = 'jitsi:visitors', password = room:get_password() or '' }):up();+ :tag(type, { xmlns = 'jitsi:visitors',+ password = type ~= 'disconnect' and room:get_password() or ''+ }):up();module:send(connect_done);end@@ -140,6 +142,8 @@ local function disconnect_vnode(event)-- we are counting vnode main participants and we should be clearing it there-- let's do it here just in casevisitors_nodes[room.jid].nodes[conference_service] = nil;++ send_visitors_iq(conference_service, room, 'disconnect');endmodule:hook('jitsi-disconnect-vnode', disconnect_vnode);@@ -159,9 +163,7 @@ module:hook('presence/full', function(event)if visitors_nodes[room_jid] and visitors_nodes[room_jid].nodesand visitors_nodes[room_jid].nodes[from_host] thenvisitors_nodes[room_jid].nodes[from_host] = visitors_nodes[room_jid].nodes[from_host] - 1;- if visitors_nodes[room_jid].nodes[from_host] == 0 then- visitors_nodes[room_jid].nodes[from_host] = nil;- end+ -- we clean only on disconnect coming from jicofoendendend, 900);