# HG changeset patch # User Matthew Wild # Date 1409132098 -3600 # Node ID 413e3f4498651c2da8460c50a9546252e056a3ad # Parent 04049524fcd1d6766b9b9180048b331c958552f8# Parent 4455b07f77edbe69633287fe3882f7bb6a7a55ae Merge with Zash diff -r 4455b07f77ed -r 413e3f449865 plugins/groupchat.lua --- a/plugins/groupchat.lua Wed Sep 04 13:40:55 2013 +0200 +++ b/plugins/groupchat.lua Wed Aug 27 10:34:58 2014 +0100 @@ -43,12 +43,11 @@ return false, "no nickname supplied" end opts = opts or {}; - local room = setmetatable({ + local room = setmetatable(verse.eventable{ stream = stream, jid = jid, nick = nick, subject = nil, occupants = {}, opts = opts, - events = events.new() }, room_mt); if opts.source then self.rooms[opts.source.." "..jid] = room; @@ -176,12 +175,3 @@ function room_mt:ban(nick, reason) self:set_affiliation(nick, "outcast", reason); end - -function room_mt:event(name, arg) - self.stream:debug("Firing room event: %s", name); - return self.events.fire_event(name, arg); -end - -function room_mt:hook(name, callback, priority) - return self.events.add_handler(name, callback, priority); -end diff -r 4455b07f77ed -r 413e3f449865 plugins/smacks.lua --- a/plugins/smacks.lua Wed Sep 04 13:40:55 2013 +0200 +++ b/plugins/smacks.lua Wed Aug 27 10:34:58 2014 +0100 @@ -1,4 +1,5 @@ local verse = require "verse"; +local now = socket.gettime; local xmlns_sm = "urn:xmpp:sm:2"; @@ -6,6 +7,8 @@ -- State for outgoing stanzas local outgoing_queue = {}; local last_ack = 0; + local last_stanza_time = now(); + local timer_active; -- State for incoming stanzas local handled_stanza_count = 0; @@ -24,11 +27,24 @@ if stanza.name and not stanza.attr.xmlns then -- serialize stanzas in order to bypass this on resumption outgoing_queue[#outgoing_queue+1] = tostring(stanza); - verse.add_task(1, function() - if #outgoing_queue > 0 then + last_stanza_time = now(); + if not timer_active then + timer_active = true; + stream:debug("Waiting to send ack request..."); + verse.add_task(1, function() + if #outgoing_queue == 0 then + timer_active = false; + return; + end + local time_since_last_stanza = now() - last_stanza_time; + if time_since_last_stanza < 1 and #outgoing_queue < 10 then + return 1 - time_since_last_stanza; + end + stream:debug("Time up, sending ..."); + timer_active = false; stream:send(verse.stanza("r", { xmlns = xmlns_sm })); - end - end); + end); + end end end