|
@@ -10,13 +10,8 @@ if muc_component_host == nil then
|
10
|
10
|
log("error", "No muc_component specified. No muc to operate on!");
|
11
|
11
|
return;
|
12
|
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
|
16
|
-- receives messages from client currently connected to the room
|
22
|
17
|
-- clients indicates their own dominant speaker events
|
|
@@ -128,7 +123,7 @@ function occupant_joined(event)
|
128
|
123
|
|
129
|
124
|
-- before sending we need to calculate current dominant speaker
|
130
|
125
|
-- state
|
131
|
|
- if values:isDominantSpeaker() ~= nil then
|
|
126
|
+ if values:isDominantSpeaker() then
|
132
|
127
|
local timeElapsed = math.floor(
|
133
|
128
|
socket.gettime()*1000 - values._dominantSpeakerStart);
|
134
|
129
|
totalDominantSpeakerTime = totalDominantSpeakerTime
|
|
@@ -184,7 +179,25 @@ function room_destroyed(event)
|
184
|
179
|
end
|
185
|
180
|
|
186
|
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
|