core/stanza_router.lua

changeset 1356
b760c0d4e012
parent 1348
ffa70c0df850
child 1358
71fbf8a52dcf
equal deleted inserted replaced
1355:42c6840ec47f 1356:b760c0d4e012
20 local sessionmanager = require "core.sessionmanager"; 20 local sessionmanager = require "core.sessionmanager";
21 local offlinemanager = require "core.offlinemanager"; 21 local offlinemanager = require "core.offlinemanager";
22 22
23 local modules_handle_stanza = require "core.modulemanager".handle_stanza; 23 local modules_handle_stanza = require "core.modulemanager".handle_stanza;
24 local component_handle_stanza = require "core.componentmanager".handle_stanza; 24 local component_handle_stanza = require "core.componentmanager".handle_stanza;
25
26 local handle_outbound_presence_subscriptions_and_probes = function()end;--require "core.presencemanager".handle_outbound_presence_subscriptions_and_probes;
27 local handle_inbound_presence_subscriptions_and_probes = function()end;--require "core.presencemanager".handle_inbound_presence_subscriptions_and_probes;
28 local handle_normal_presence = function()end;--require "core.presencemanager".handle_normal_presence;
29 25
30 local format = string.format; 26 local format = string.format;
31 local tostring = tostring; 27 local tostring = tostring;
32 local t_concat = table.concat; 28 local t_concat = table.concat;
33 local t_insert = table.insert; 29 local t_insert = table.insert;
226 res.send(stanza); -- Yay \o/ 222 res.send(stanza); -- Yay \o/
227 else 223 else
228 -- if we get here, resource was not specified or was unavailable 224 -- if we get here, resource was not specified or was unavailable
229 if stanza.name == "presence" then 225 if stanza.name == "presence" then
230 if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then 226 if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then
231 handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare, core_route_stanza); 227 -- inbound presence subscriptions and probes, already handled, so should never get here
232 elseif not resource then -- sender is available or unavailable or error 228 elseif not resource then -- sender is available or unavailable or error
233 for _, session in pairs(user.sessions) do -- presence broadcast to all user resources. 229 for _, session in pairs(user.sessions) do -- presence broadcast to all user resources.
234 if session.full_jid then -- FIXME should this be just for available resources? Do we need to check subscription? 230 if session.full_jid then -- FIXME should this be just for available resources? Do we need to check subscription?
235 stanza.attr.to = session.full_jid; -- reset at the end of function 231 stanza.attr.to = session.full_jid; -- reset at the end of function
236 session.send(stanza); 232 session.send(stanza);
266 else 262 else
267 -- user not online 263 -- user not online
268 if user_exists(node, host) then 264 if user_exists(node, host) then
269 if stanza.name == "presence" then 265 if stanza.name == "presence" then
270 if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then 266 if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then
271 handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare, core_route_stanza); 267 -- inbound presence subscriptions and probes, already handled, so should never get here
272 else 268 else
273 -- TODO send unavailable presence or unsubscribed 269 -- TODO send unavailable presence or unsubscribed
274 end 270 end
275 elseif stanza.name == "message" then -- FIXME if full jid, then send out to resources with highest priority 271 elseif stanza.name == "message" then -- FIXME if full jid, then send out to resources with highest priority
276 stanza.attr.to = to_bare; -- TODO not in RFC, but seems obvious. Should discuss on the mailing list. 272 stanza.attr.to = to_bare; -- TODO not in RFC, but seems obvious. Should discuss on the mailing list.

mercurial