You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mod_jiconop.lua 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. local st = require "util.stanza";
  2. local get_services = module:depends("external_services").get_services;
  3. -- Jitsi Connection Optimization
  4. -- gathers needed information and pushes it with a message to clients
  5. -- this way we skip 4 request responses during every client setup
  6. local shard_name_config = module:get_option_string('shard_name');
  7. if shard_name_config then
  8. module:add_identity("server", "shard", shard_name_config);
  9. end
  10. -- this is after xmpp-bind, the moment a client has resource and can be contacted
  11. module:hook("resource-bind", function (event)
  12. local session = event.session;
  13. -- disco info data / all identity and features
  14. local query = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" });
  15. local done = {};
  16. for _,identity in ipairs(module:get_host_items("identity")) do
  17. local identity_s = identity.category.."\0"..identity.type;
  18. if not done[identity_s] then
  19. query:tag("identity", identity):up();
  20. done[identity_s] = true;
  21. end
  22. end
  23. -- check whether room has lobby enabled and display name is required for those trying to join
  24. local lobby_muc_component_config = module:get_option_string('lobby_muc');
  25. module:context(lobby_muc_component_config):fire_event('host-disco-info-node',
  26. {origin = session; reply = query; node = 'lobbyrooms';});
  27. local stanza = st.message({
  28. type = 'service-info';
  29. from = module.host;
  30. to = session.full_jid; });
  31. stanza:add_child(query):up();
  32. --- get turnservers and credentials
  33. local services = get_services();
  34. stanza:tag("services");
  35. for _, srv in ipairs(services) do
  36. stanza:tag("service", srv):up();
  37. end
  38. session.send(stanza);
  39. end);