Software / code / prosody-modules
Comparison
mod_admin_web/admin_web/mod_admin_web.lua @ 303:0f53c88bab9a
mod_admin_web: Move pubsub service initialisation into a server-started handler, in case we get loaded before the service
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 27 Dec 2010 04:24:44 +0000 |
| parent | 301:b241c79a0eb7 |
| child | 304:8f3499ae1e27 |
comparison
equal
deleted
inserted
replaced
| 302:50abf9922e6e | 303:0f53c88bab9a |
|---|---|
| 149 | 149 |
| 150 function module.load() | 150 function module.load() |
| 151 local host_session = prosody.hosts[host]; | 151 local host_session = prosody.hosts[host]; |
| 152 local http_conf = config.get("*", "core", "webadmin_http_ports"); | 152 local http_conf = config.get("*", "core", "webadmin_http_ports"); |
| 153 | 153 |
| 154 httpserver.new_from_config(http_conf, handle_file_request, { base = "admin" }); | |
| 155 end | |
| 156 | |
| 157 module:hook("server-started", function () | |
| 154 if not select(2, hosts[service].modules.pubsub.service:get_nodes(service))[xmlns_s2s_session] then | 158 if not select(2, hosts[service].modules.pubsub.service:get_nodes(service))[xmlns_s2s_session] then |
| 155 local ok, errmsg = hosts[service].modules.pubsub.service:create(xmlns_s2s_session, service); | 159 local ok, errmsg = hosts[service].modules.pubsub.service:create(xmlns_s2s_session, service); |
| 156 if not ok then | 160 if not ok then |
| 157 module:log("warn", "Could not create node " .. xmlns_s2s_session .. ": " .. tostring(errmsg)); | 161 module:log("warn", "Could not create node " .. xmlns_s2s_session .. ": " .. tostring(errmsg)); |
| 158 end | 162 end |
| 179 for username, user in pairs(host_session.sessions or {}) do | 183 for username, user in pairs(host_session.sessions or {}) do |
| 180 for resource, session in pairs(user.sessions or {}) do | 184 for resource, session in pairs(user.sessions or {}) do |
| 181 add_client(session); | 185 add_client(session); |
| 182 end | 186 end |
| 183 end | 187 end |
| 184 | 188 end); |
| 185 httpserver.new_from_config(http_conf, handle_file_request, { base = "admin" }); | |
| 186 end | |
| 187 | 189 |
| 188 module:hook("resource-bind", function(event) | 190 module:hook("resource-bind", function(event) |
| 189 add_client(event.session); | 191 add_client(event.session); |
| 190 end); | 192 end); |
| 191 | 193 |