# HG changeset patch # User Kim Alvefur # Date 1484053916 -3600 # Node ID 7814a5c7fee8418210d85c267c64c055eceadf4e # Parent 1f7820f68868123b9e824951c60b32bd4f59caea mod_candy: Provide websocket URI if mod_websocket is loaded, fall back to BOSH diff -r 1f7820f68868 -r 7814a5c7fee8 mod_candy/mod_candy.lua --- a/mod_candy/mod_candy.lua Sun Jan 08 11:29:13 2017 +0100 +++ b/mod_candy/mod_candy.lua Tue Jan 10 14:11:56 2017 +0100 @@ -1,19 +1,29 @@ -- mod_candy.lua --- Copyright (C) 2013 Kim Alvefur +-- Copyright (C) 2013-2017 Kim Alvefur local json_encode = require"util.json".encode; +local is_module_loaded = require "core.modulemanager".is_loaded; -module:depends"bosh"; local serve = module:depends"http_files".serve; module:provides("http", { route = { ["GET /prosody.js"] = function(event) event.response.headers.content_type = "text/javascript"; + local connect_path; + if is_module_loaded(module.host, "websocket") then + connect_path = module:http_url("websocket", "xmpp-websocket"):gsub("^http", "ws"); + else + if not is_module_loaded(module.host, "bosh") then + module:depends("bosh"); + end + connect_path = module:http_url("bosh", "/http-bind"); + end + return ("// Generated by Prosody\n" .."var Prosody = %s;\n") :format(json_encode({ - bosh_path = module:http_url("bosh","/http-bind"); + connect_path = connect_path; version = prosody.version; host = module:get_host(); anonymous = module:get_option_string("authentication") == "anonymous"; diff -r 1f7820f68868 -r 7814a5c7fee8 mod_candy/www_files/index.html --- a/mod_candy/www_files/index.html Sun Jan 08 11:29:13 2017 +0100 +++ b/mod_candy/www_files/index.html Tue Jan 10 14:11:56 2017 +0100 @@ -13,7 +13,7 @@