From 30de4348013dc1f21e916f1b2bb198369ff024bf Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 25 Oct 2008 06:49:48 +0500 Subject: Routing code reorganization --- core/sessionmanager.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'core/sessionmanager.lua') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index a7858d9e..db898693 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -115,4 +115,21 @@ function streamopened(session, attr) session.notopen = nil; end +function send_to_available_resources(user, host, stanza) + local to = stanza.attr.to; + stanza.attr.to = nil; + local h = hosts[host]; + if h and h.type == "local" then + local u = h.sessions[user]; + if u then + for k, session in pairs(u.sessions) do + if session.presence then + session.send(stanza); + end + end + end + end + stanza.attr.to = to; +end + return _M; \ No newline at end of file -- cgit v1.2.3 From 091e961c40b6d89f548efecea07e641e3f9c4210 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 25 Oct 2008 21:16:08 +0500 Subject: Outbound presence subscription --- core/sessionmanager.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core/sessionmanager.lua') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index db898693..82a001c1 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -116,6 +116,7 @@ function streamopened(session, attr) end function send_to_available_resources(user, host, stanza) + local count = 0; local to = stanza.attr.to; stanza.attr.to = nil; local h = hosts[host]; @@ -125,11 +126,13 @@ function send_to_available_resources(user, host, stanza) for k, session in pairs(u.sessions) do if session.presence then session.send(stanza); + count = count + 1; end end end end stanza.attr.to = to; + return count; end return _M; \ No newline at end of file -- cgit v1.2.3