Hi,
I am writing an ejabberd module to filter packets. I need to get the hostname to pull some configs using gen_mod:get_module_opt() .
I have 4 important functions :
- start(Host, _Opt) : This is an ejabberd function to load my module. I get the 'Host' atom here
- filter_packet({From, To, XML}) : This is my packet filter hook. I cannot pass custom params to this function, as it is a hook in ejabberd.
- get_translation(XmlData) : 'filter_packet()' calls 'get_translation()' in a loop
- fetch_translation( XmlData ) : called recursively from 'get_translation()'. This is where i am calling 'gen_mod:get_module_opt()', and hence need the 'Host'.
My question is, how can i take 'Host' from 'start()' and put it in a global variable, so that 'fetch_translation' can access it.
PS: I'm a newbie at erlang
Thanks, Adil