Mercurial > prosody-hg
comparison util/xmlrpc.lua @ 1497:4c2c403ca04b
util.xmlrpc: Add create_request
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 08 Jul 2009 15:11:11 +0100 |
| parents | 2c0b9e3c11c3 |
| children | 481dfc89047a |
comparison
equal
deleted
inserted
replaced
| 1496:4fa337035f46 | 1497:4c2c403ca04b |
|---|---|
| 64 _lua_to_xmlrpc(stanza, {faultCode=faultCode, faultString=faultString}); | 64 _lua_to_xmlrpc(stanza, {faultCode=faultCode, faultString=faultString}); |
| 65 stanza:up():up(); | 65 stanza:up():up(); |
| 66 return stanza; | 66 return stanza; |
| 67 end | 67 end |
| 68 | 68 |
| 69 function create_request(method_name, object) | |
| 70 local stanza = st.stanza("methodCall") | |
| 71 :tag("methodName"):text(method_name):up() | |
| 72 :tag("params"):tag("param"):tag("value"); | |
| 73 _lua_to_xmlrpc(stanza, object); | |
| 74 stanza:up():up():up(); | |
| 75 return stanza; | |
| 76 end | |
| 69 | 77 |
| 70 local _xmlrpc_to_lua; | 78 local _xmlrpc_to_lua; |
| 71 local int_parse = function(stanza) | 79 local int_parse = function(stanza) |
| 72 if #stanza.tags ~= 0 or #stanza == 0 then error("<"..stanza.name.."> must have a single text child"); end | 80 if #stanza.tags ~= 0 or #stanza == 0 then error("<"..stanza.name.."> must have a single text child"); end |
| 73 local n = tonumber(t_concat(stanza)); | 81 local n = tonumber(t_concat(stanza)); |
