examples/iq.lua
author Myhailo Danylenko <isbear@ukrpost.net>
Sat, 21 Mar 2009 05:04:46 +0200
changeset 43 7c22b1f2c6e5
child 49 95f3bf77c598
permissions -rw-r--r--
Iq separation


-- 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 () ) -- FIXME
			else
				fail ( mess:xml () )
				return false
			end
			return true
		end )
end

-- vim: se ts=4: --