Software /
code /
verse
Changeset
179:5e2ff25c1dd9
plugins.disco: Use the new presence plugin for caching and resending
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 31 Dec 2010 02:12:27 +0100 |
parents | 178:2189f75e09b9 |
children | 180:58537eb98506 |
files | plugins/disco.lua |
diffstat | 1 files changed, 3 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/disco.lua Fri Dec 31 01:32:26 2010 +0100 +++ b/plugins/disco.lua Fri Dec 31 02:12:27 2010 +0100 @@ -31,8 +31,6 @@ stream.caps = {} stream.caps.node = 'http://code.matthewwild.co.uk/verse/' - local _resend_presence; -- Forward declaration of a function - local function cmp_identity(item1, item2) if item1.category < item2.category then return true; @@ -91,14 +89,14 @@ function stream:add_disco_feature(feature) table.insert(self.disco.info.features, {var=feature}); - _resend_presence(); + stream:resend_presence(); end function stream:remove_disco_feature(feature) for idx, disco_feature in ipairs(self.disco.info.features) do if disco_feature.var == feature then table.remove(self.disco.info.features, idx); - _resend_presence(); + stream:resend_presence(); return true; end end @@ -379,29 +377,11 @@ return true; end, 5); - local last_presence; -- Cache to re-send with updated caps - stream:hook("presence-out", function (presence) if not presence:get_child("c", xmlns_caps) then presence:reset():add_child(stream:caps()):reset(); end - if not presence.attr.to then - last_presence = presence; -- Cache non-directed presence - end - end); - - local function update_caps(tag) - if tag.name == "c" and tag.attr.xmlns == xmlns_caps then - return stream:caps(); - end - end - - function _resend_presence() -- Local via forward declaration - if last_presence then - last_presence = last_presence:maptags(update_caps); - stream:send(last_presence); - end - end + end, 10); end -- end of disco.lua