# File lib/xmpp4r/rpc/helper/client.rb, line 44 def call(method, *args) ok, param = call2(method, *args) if ok param else raise param end end
# File lib/xmpp4r/rpc/helper/client.rb, line 53 def call2(method, *args) request = @create.methodCall(method, *args) data = do_rpc(request) parser().parseMethodResponse(data) end
# File lib/xmpp4r/rpc/helper/client.rb, line 78 def do_rpc(xmlrpc) iq = Iq.new(:set, @jid) iq.from = @my_jid iq.id = IdGenerator::generate_id rpcquery = iq.add(IqQueryRPC.new) rpcquery.typed_add(xmlrpc) result = nil @stream.send_with_id(iq) do |iqreply| if iqreply.query.kind_of?(IqQueryRPC) result = iqreply.query.to_s end end result end
automatically trys to find a method thanx to eric cestari :)
# File lib/xmpp4r/rpc/helper/client.rb, line 39 def method_missing(methodname, *args) send("call", methodname,*args) end
adds multi rpcalls to the query
# File lib/xmpp4r/rpc/helper/client.rb, line 62 def multicall(*methods) ok, params = multicall2(*methods) if ok params else raise params end end
generate a multicall
# File lib/xmpp4r/rpc/helper/client.rb, line 74 def multicall2(*methods) gen_multicall(methods) end
# File lib/xmpp4r/rpc/helper/client.rb, line 97 def gen_multicall(methods=[]) ok, params = call2("system.multicall", methods.collect { |m| { 'methodName' => m[0], 'params' => m[1..-1] } } ) if ok params = params.collect{ |param| if param.is_a? Array param[0] elsif param.is_a? Hash XMLRPC::FaultException.new(param["faultCode"], param["faultString"]) else raise "Wrong multicall return value" end } end return ok, params end