1

I try to setup a special behavior with Jitsi, but have not that much LUA knowlege.

A Jitsi/Prosody module "mod_muc_lobby_rooms.lua" is implementing some function like handle_create_lobby(event);. handle_create_lobby is calling other sub-function from inside.

https://github.com/jitsi/jitsi-meet/blob/master/resources/prosody-plugins/mod_muc_lobby_rooms.lua

But the module itself is not a library module, so no table is exported and another code can use "require". So my understanding from LUA yet.

For a own module, I just want use this functions from the other side, without reimplement or copy/paste it.

Is there any solution, how I can "source" the function into my module?

If possible, I want let "mod_muc_lobby_room.lua" unchanged, if some updates from Jitsi are coming.

Thanks in advance.

A lua beginner, Uwe

Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
ula.uvula
  • 158
  • 13
  • 2
    Function `handle_create_lobby` is a global function. The module `mod_muc_lobby_room` saves this function to global variables, so after that the function is available to all your code. – Egor Skriptunoff Apr 01 '21 at 09:34
  • @EgorSkriptunoff not sure about this `Attempt to read a non-existent global 'handle_create_lobby'`. – L3opold Apr 06 '21 at 09:25
  • This means you have not loaded the library before trying to access the global variable. – Egor Skriptunoff Apr 06 '21 at 09:51
  • 1
    Thanks for hints, but it was not working, because the modul "mod_muc_lobby_rooms" was loaded within another prosody phase (VirtualHost a vs. b). For me it looks like the modules do not see each other. But finally the answer from L3opold helped me alot. It works for me. So I can build my own module, using function from other module. – ula.uvula Apr 06 '21 at 10:37

2 Answers2

1

You can fire an event because it listen for it.

prosody.events.fire_event("create-lobby-room", event)

Or you can use the module function like this:

local muc_lobby_rooms = module:depends("muc_lobby_rooms");
muc_lobby_rooms.handle_create_lobby(event);
L3opold
  • 91
  • 3
  • Thanks L3opold. Works great. So I can build my own module and enable by default the lobby, when a room organisator is starting the room with a JWT. You made my day :-) – ula.uvula Apr 06 '21 at 10:39
0

You can do it like that:

file=io.open("mod_muc_lobby_room.lua")
io.input(file)
load(io.read("*a"))()
io.close(file)

And the code located in mod_muc_lobby_room.lua will be executed.

Excalibur
  • 151
  • 3
  • 9