浏览代码

fix(visitors): Destroy visitors room earlier on main=0.

Sometimes jicofo may leave before the disconnect iq reaches the visitor prosody, that will cause a reload for all visitors instead of a dialog for conference ended.
factor2
damencho 8 个月前
父节点
当前提交
8d8e83cdfd
共有 1 个文件被更改,包括 19 次插入7 次删除
  1. 19
    7
      resources/prosody-plugins/mod_fmuc.lua

+ 19
- 7
resources/prosody-plugins/mod_fmuc.lua 查看文件

@@ -211,6 +211,20 @@ local function cancel_destroy_timer(room)
211 211
     end
212 212
 end
213 213
 
214
+local function destroy_with_conference_ended(room)
215
+    -- if the room is being destroyed, ignore
216
+    if room.destroying then
217
+        return;
218
+    end
219
+
220
+    cancel_destroy_timer(room);
221
+
222
+    local main_count, visitors_count = get_occupant_counts(room);
223
+    module:log('info', 'Will destroy:%s main_occupants:%s visitors:%s', room.jid, main_count, visitors_count);
224
+    room:destroy(nil, 'Conference ended.');
225
+    return true;
226
+end
227
+
214 228
 -- schedules a new destroy timer which will destroy the room if there are no visitors after the timeout
215 229
 local function schedule_destroy_timer(room)
216 230
     cancel_destroy_timer(room);
@@ -271,6 +285,10 @@ module:hook('muc-occupant-left', function (event)
271 285
     if visitors_count == 0 then
272 286
         schedule_destroy_timer(room);
273 287
     end
288
+
289
+    if main_count == 0 then
290
+        destroy_with_conference_ended(room);
291
+    end
274 292
 end);
275 293
 
276 294
 -- forward visitor presences to jicofo
@@ -407,7 +425,6 @@ local function stanza_handler(event)
407 425
     local room = get_room_from_jid(room_jid_match_rewrite(room_jid));
408 426
 
409 427
     if not room then
410
-        module:log('warn', 'No room found %s in stanza_handler', room_jid);
411 428
         return;
412 429
     end
413 430
 
@@ -619,12 +636,7 @@ local function iq_from_main_handler(event)
619 636
     respond_iq_result(origin, stanza);
620 637
 
621 638
     if process_disconnect then
622
-        cancel_destroy_timer(room);
623
-
624
-        local main_count, visitors_count = get_occupant_counts(room);
625
-        module:log('info', 'Will destroy:%s main_occupants:%s visitors:%s', room.jid, main_count, visitors_count);
626
-        room:destroy(nil, 'Conference ended.');
627
-        return true;
639
+        return destroy_with_conference_ended(room);
628 640
     end
629 641
 
630 642
     -- if there is password supplied use it

正在加载...
取消
保存