examples/iq.lua
author Myhailo Danylenko <isbear@ukrpost.net>
Mon, 23 Mar 2009 08:15:47 +0200
changeset 62 fb81aeb45e00
parent 49 95f3bf77c598
child 64 bf7521ed96eb
permissions -rw-r--r--
Vcard and Evil


-- CORE, IQ

-- library

require 'lm'

-- public

iq = { }

function iq.send ( conn, to, smtype, data, success, fail )
	data.mtype = 'iq-' .. smtype
	data.to    = to
	conn:send ( lm.message.create ( data ),
		function ( conn, mess )
			local mtype, smtype = mess:type ()
			if smtype == 'result' then
				success ( mess )
			elseif smtype == 'error' then
				fail ( mess:child( 'error' ):children():name (), mess ) -- FIXME
			else
				fail ( mess:xml (), mess )
				return false
			end
			return true
		end )
end

-- vim: se ts=4: --