Mercurial > prosody-modules
comparison mod_post_msg/mod_post_msg.lua @ 320:8d4f3cd41f82
mod_post_msg: Better initialization
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 27 Jan 2011 17:30:48 +0100 |
| parents | b78009874ce5 |
| children | 661f64627fed |
comparison
equal
deleted
inserted
replaced
| 319:ba2e78661ea8 | 320:8d4f3cd41f82 |
|---|---|
| 103 module:log("debug", "message for %s", to_jid) | 103 module:log("debug", "message for %s", to_jid) |
| 104 core_post_stanza(hosts[module.host], stanza) | 104 core_post_stanza(hosts[module.host], stanza) |
| 105 return http_response(202, "Accepted") | 105 return http_response(202, "Accepted") |
| 106 end | 106 end |
| 107 | 107 |
| 108 local ports = config.get(module.host, "core", "post_msg_ports") or { 5280 }; | 108 local function setup() |
| 109 require "net.httpserver".new_from_config(ports, "msg", handle_request); | 109 local ports = module:get_option("post_msg_ports") or { 5280 }; |
| 110 require "net.httpserver".new_from_config(ports, handle_request, { base = "msg" }); | |
| 111 end | |
| 112 if prosody.start_time then -- already started | |
| 113 setup(); | |
| 114 else | |
| 115 prosody.events.add_handler("server-started", setup); | |
| 116 end |
