Software /
code /
prosody-modules
Comparison
mod_saslauth_muc/mod_saslauth_muc.lua @ 287:6144fe6161f1
mod_saslauth_muc: Improved timer handling.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 14 Dec 2010 00:03:24 +0500 |
parent | 284:3b96bba9f7e5 |
child | 305:4c3abf1a9b5a |
comparison
equal
deleted
inserted
replaced
286:ca6199d73d68 | 287:6144fe6161f1 |
---|---|
40 _rooms[room_jid][jid].timeout = os_time() + timeout; | 40 _rooms[room_jid][jid].timeout = os_time() + timeout; |
41 return _rooms[room_jid][jid]; | 41 return _rooms[room_jid][jid]; |
42 end | 42 end |
43 | 43 |
44 -- Timer to clear SASL sessions | 44 -- Timer to clear SASL sessions |
45 timer.add_task(timeout, function() | 45 timer.add_task(timeout, function(now) |
46 local now = os_time(); | |
47 for room, handlers in pairs(_rooms) do | 46 for room, handlers in pairs(_rooms) do |
48 for jid, handler in pairs(handlers) do | 47 for jid, handler in pairs(handlers) do |
49 if handler.timeout <= now then handlers[jid] = nil; end | 48 if handler.timeout <= now then handlers[jid] = nil; end |
50 end | 49 end |
51 if next(handlers) == nil then _rooms[room] = nil; end | 50 if next(handlers) == nil then _rooms[room] = nil; end |
52 end | 51 end |
53 return timeout; | 52 return timeout; |
54 end); | 53 end); |
54 function module.unload() | |
55 timeout = nil; -- stop timer on unload | |
56 end | |
55 | 57 |
56 -- Stanza handlers | 58 -- Stanza handlers |
57 module:hook("presence/full", function(event) | 59 module:hook("presence/full", function(event) |
58 local origin, stanza = event.origin, event.stanza; | 60 local origin, stanza = event.origin, event.stanza; |
59 | 61 |