68
|
1 |
|
|
2 |
-- CORE, IQ |
|
3 |
|
|
4 |
-- library |
|
5 |
|
|
6 |
local lm = require 'lm' |
|
7 |
|
|
8 |
-- |
|
9 |
|
|
10 |
local F = { } |
|
11 |
|
|
12 |
function F.send ( conn, to, smtype, data, success, fail ) |
|
13 |
data.mtype = 'iq-' .. smtype |
|
14 |
data.to = to |
|
15 |
conn:send ( lm.message.create ( data ), |
|
16 |
function ( conn, mess ) |
|
17 |
local mtype, smtype = mess:type () |
|
18 |
if smtype == 'result' then |
|
19 |
success ( mess ) |
|
20 |
elseif smtype == 'error' then |
|
21 |
fail ( mess:child( 'error' ):child():name (), mess ) -- FIXME |
|
22 |
else |
|
23 |
fail ( mess:xml (), mess ) |
|
24 |
return false |
|
25 |
end |
|
26 |
return true |
|
27 |
end ) |
|
28 |
end |
|
29 |
|
|
30 |
return F |
|
31 |
|
|
32 |
-- vim: se ts=4: -- |