author | Myhailo Danylenko <isbear@ukrpost.net> |
Fri, 27 Mar 2009 01:46:53 +0200 | |
changeset 64 | bf7521ed96eb |
parent 49 | 95f3bf77c598 |
child 66 | 542f61e113cb |
permissions | -rw-r--r-- |
43 | 1 |
|
2 |
-- CORE, IQ |
|
3 |
||
4 |
-- library |
|
5 |
||
6 |
require 'lm' |
|
7 |
||
8 |
-- public |
|
9 |
||
64
bf7521ed96eb
Rewrite of ibb in object style
Myhailo Danylenko <isbear@ukrpost.net>
parents:
49
diff
changeset
|
10 |
local F = { } |
43 | 11 |
|
64
bf7521ed96eb
Rewrite of ibb in object style
Myhailo Danylenko <isbear@ukrpost.net>
parents:
49
diff
changeset
|
12 |
function F.send ( conn, to, smtype, data, success, fail ) |
43 | 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 |
|
49 | 21 |
fail ( mess:child( 'error' ):children():name (), mess ) -- FIXME |
43 | 22 |
else |
49 | 23 |
fail ( mess:xml (), mess ) |
43 | 24 |
return false |
25 |
end |
|
26 |
return true |
|
27 |
end ) |
|
28 |
end |
|
29 |
||
64
bf7521ed96eb
Rewrite of ibb in object style
Myhailo Danylenko <isbear@ukrpost.net>
parents:
49
diff
changeset
|
30 |
return F |
bf7521ed96eb
Rewrite of ibb in object style
Myhailo Danylenko <isbear@ukrpost.net>
parents:
49
diff
changeset
|
31 |
|
43 | 32 |
-- vim: se ts=4: -- |