mod_http_altconnect/mod_http_altconnect.lua
changeset 3716 0a0bf87ccda6
parent 1325 b21236b6b8d8
equal deleted inserted replaced
3715:309fa523c424 3716:0a0bf87ccda6
     1 -- mod_http_altconnect
     1 -- mod_http_altconnect
     2 -- XEP-0156: Discovering Alternative XMPP Connection Methods
     2 -- XEP-0156: Discovering Alternative XMPP Connection Methods
     3 
     3 
     4 module:depends"http";
     4 module:depends"http";
     5 
     5 
       
     6 local mm = require "core.modulemanager";
     6 local json = require"util.json";
     7 local json = require"util.json";
     7 local st = require"util.stanza";
     8 local st = require"util.stanza";
     8 local array = require"util.array";
     9 local array = require"util.array";
     9 
    10 
    10 local host_modules = hosts[module.host].modules;
       
    11 
       
    12 local function get_supported()
    11 local function get_supported()
    13 	local uris = array();
    12 	local uris = array();
    14 	if host_modules["bosh"] then
    13 	if mm.is_loaded(module.host, "bosh") or  mm.is_loaded("*", "bosh") then
    15 		uris:push({ rel = "urn:xmpp:alt-connections:xbosh", href = module:http_url("bosh", "/http-bind") });
    14 		uris:push({ rel = "urn:xmpp:alt-connections:xbosh", href = module:http_url("bosh", "/http-bind") });
    16 	end
    15 	end
    17 	if host_modules["websocket"] then
    16 	if mm.is_loaded(module.host, "websocket") or  mm.is_loaded("*", "websocket") then
    18 		uris:push({ rel = "urn:xmpp:alt-connections:websocket", href = module:http_url("websocket", "xmpp-websocket"):gsub("^http", "ws") });
    17 		uris:push({ rel = "urn:xmpp:alt-connections:websocket", href = module:http_url("websocket", "xmpp-websocket"):gsub("^http", "ws") });
    19 	end
    18 	end
    20 	return uris;
    19 	return uris;
    21 end
    20 end
    22 
    21