Software /
code /
verse
Comparison
plugins/disco.lua @ 109:60a03b2cabec
verse.plugins.disco: Auto-disco local services on connect, and delay 'ready' event until done
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 24 Aug 2010 11:11:17 +0100 |
parent | 99:0f5a8d530fcd |
child | 112:4f8429727316 |
comparison
equal
deleted
inserted
replaced
108:c67ed3fc5571 | 109:60a03b2cabec |
---|---|
330 }):add_child(result)) | 330 }):add_child(result)) |
331 return true | 331 return true |
332 end | 332 end |
333 end); | 333 end); |
334 | 334 |
335 local initial_disco_started; | |
335 stream:hook("ready", function () | 336 stream:hook("ready", function () |
337 if initial_disco_started then return; end | |
338 initial_disco_started = true; | |
336 stream:disco_local_services(function (services) | 339 stream:disco_local_services(function (services) |
337 for _, service in ipairs(services) do | 340 for _, service in ipairs(services) do |
338 for identity in pairs(stream.disco.cache[service.jid].identities) do | 341 for identity in pairs(stream.disco.cache[service.jid].identities) do |
339 local category, type = identity:match("^(.*)/(.*)$"); | 342 local category, type = identity:match("^(.*)/(.*)$"); |
340 stream:event("disco/service-discovered/"..category, { | 343 stream:event("disco/service-discovered/"..category, { |
341 type = type, jid = service.jid; | 344 type = type, jid = service.jid; |
342 }); | 345 }); |
343 end | 346 end |
344 end | 347 end |
348 stream:event("ready"); | |
345 end); | 349 end); |
350 return true; | |
346 end, 5); | 351 end, 5); |
347 end | 352 end |
348 | 353 |
349 -- end of disco.lua | 354 -- end of disco.lua |