소스 검색

Updates correct loading and fix checking is dominant speaker.

master
damencho 5 년 전
부모
커밋
a5fc62b920
1개의 변경된 파일24개의 추가작업 그리고 11개의 파일을 삭제
  1. 24
    11
      resources/prosody-plugins/mod_speakerstats_component.lua

+ 24
- 11
resources/prosody-plugins/mod_speakerstats_component.lua 파일 보기

10
     log("error", "No muc_component specified. No muc to operate on!");
10
     log("error", "No muc_component specified. No muc to operate on!");
11
     return;
11
     return;
12
 end
12
 end
13
-local muc_module = module:context("conference."..muc_component_host);
14
-if muc_module == nil then
15
-    log("error", "No such muc found, check muc_component config.");
16
-    return;
17
-end
18
 
13
 
19
-log("debug", "Starting speakerstats for %s", muc_component_host);
14
+log("info", "Starting speakerstats for %s", muc_component_host);
20
 
15
 
21
 -- receives messages from client currently connected to the room
16
 -- receives messages from client currently connected to the room
22
 -- clients indicates their own dominant speaker events
17
 -- clients indicates their own dominant speaker events
128
 
123
 
129
                     -- before sending we need to calculate current dominant speaker
124
                     -- before sending we need to calculate current dominant speaker
130
                     -- state
125
                     -- state
131
-                    if values:isDominantSpeaker() ~= nil then
126
+                    if values:isDominantSpeaker() then
132
                         local timeElapsed = math.floor(
127
                         local timeElapsed = math.floor(
133
                             socket.gettime()*1000 - values._dominantSpeakerStart);
128
                             socket.gettime()*1000 - values._dominantSpeakerStart);
134
                         totalDominantSpeakerTime = totalDominantSpeakerTime
129
                         totalDominantSpeakerTime = totalDominantSpeakerTime
184
 end
179
 end
185
 
180
 
186
 module:hook("message/host", on_message);
181
 module:hook("message/host", on_message);
187
-muc_module:hook("muc-room-created", room_created, -1);
188
-muc_module:hook("muc-occupant-joined", occupant_joined, -1);
189
-muc_module:hook("muc-occupant-pre-leave", occupant_leaving, -1);
190
-muc_module:hook("muc-room-destroyed", room_destroyed, -1);
182
+
183
+-- executed on every host added internally in prosody, including components
184
+function process_host(host)
185
+    if host == muc_component_host then -- the conference muc component
186
+        module:log("info","Hook to muc events on %s", host);
187
+
188
+        local muc_module = module:context(host);
189
+        muc_module:hook("muc-room-created", room_created, -1);
190
+        muc_module:hook("muc-occupant-joined", occupant_joined, -1);
191
+        muc_module:hook("muc-occupant-pre-leave", occupant_leaving, -1);
192
+        muc_module:hook("muc-room-destroyed", room_destroyed, -1);
193
+    end
194
+end
195
+
196
+if prosody.hosts[muc_component_host] == nil then
197
+    module:log("info","No muc component found, will listen for it: %s", muc_component_host)
198
+
199
+    -- when a host or component is added
200
+    prosody.events.add_handler("host-activated", process_host);
201
+else
202
+    process_host(muc_component_host);
203
+end

Loading…
취소
저장