瀏覽代碼

FIX: prosody jibri queue handle iq properly

j8
Aaron van Meerten 4 年之前
父節點
當前提交
51fd10278b
共有 1 個文件被更改,包括 32 次插入25 次删除
  1. 32
    25
      resources/prosody-plugins/mod_jibri_queue_component.lua

+ 32
- 25
resources/prosody-plugins/mod_jibri_queue_component.lua 查看文件

@@ -180,37 +180,42 @@ local function sendEvent(type,room_address,participant,edetails)
180 180
     }, cb);
181 181
 end
182 182
 
183
-function on_message(event)
183
+-- receives iq from client currently connected to the room
184
+function on_iq(event)
184 185
     -- Check the type of the incoming stanza to avoid loops:
185 186
     if event.stanza.attr.type == "error" then
186 187
         return; -- We do not want to reply to these, so leave.
187 188
     end
188
-
189
-    local jibriQueue
190
-        = jibriQueue.stanza:get_child('jibriqueue', 'http://jitsi.org/jitmeet');
191
-    if jibriQueue then
192
-        local roomAddress = jibriQueue.attr.room;
193
-        local room = get_room_from_jid(room_jid_match_rewrite(roomAddress));
194
-
195
-        if not room then
196
-            log("warn", "No room found %s", roomAddress);
197
-            return false;
198
-        end
199
-
200
-        local from = event.stanza.attr.from;
201
-
202
-        local occupant = room:get_occupant_by_real_jid(from);
203
-        if not occupant then
204
-            log("warn", "No occupant %s found for %s", from, roomAddress);
205
-            return false;
189
+    if event.stanza.attr.to == module:get_host() then
190
+        if event.stanza.attr.type == "set" then
191
+            log("info", "Jibri Queue Messsage Event found: %s ",inspect(event.stanza));
192
+
193
+            local jibriQueue
194
+                = event.stanza:get_child('jibriqueue', 'http://jitsi.org/protocol/jibri-queue');
195
+            if jibriQueue then
196
+                log("info", "Jibri Queue: %s ",inspect(jibriQueue));
197
+                local roomAddress = jibriQueue.attr.room;
198
+                local room = get_room_from_jid(room_jid_match_rewrite(roomAddress));
199
+
200
+                if not room then
201
+                    log("warn", "No room found %s", roomAddress);
202
+                    return false;
203
+                end
204
+
205
+                local from = event.stanza.attr.from;
206
+
207
+                local occupant = room:get_occupant_by_real_jid(from);
208
+                if not occupant then
209
+                    log("warn", "No occupant %s found for %s", from, roomAddress);
210
+                    return false;
211
+                end
212
+                -- now handle new jibri queue message
213
+                local edetails = {
214
+                    ["foo"] = "bar"
215
+                }
216
+                sendEvent('JoinQueue',room.jid,occupant.jid,edetails)
217
+            end
206 218
         end
207
-        -- now handle new jibri queue message
208
-        local edetails = {
209
-            ["foo"] = "bar"
210
-        }
211
-        sendEvent('Message',roomAddress,from,edetails)
212 219
     end
213 220
     return true
214 221
 end
@@ -232,7 +237,7 @@ function occupant_joined(event)
232 237
     sendEvent('Join',room.jid,occupant.jid,edetails)
233 238
 end
234 239
 
235
-module:hook("message/host", on_message);
240
+module:hook("iq/host", on_iq);
236 241
 
237 242
 -- executed on every host added internally in prosody, including components
238 243
 function process_host(host)

Loading…
取消
儲存