Class: Jabber::RPC::Client
- Inherits:
-
Object
- Object
- Jabber::RPC::Client
- Includes:
- XMLRPC::ParseContentType, XMLRPC::ParserWriterChooseMixin
- Defined in:
- lib/xmpp4r/rpc/helper/client.rb
Overview
XMLRPC Client
Instance Attribute Summary collapse
-
#my_jid ⇒ Object
Returns the value of attribute my_jid.
Instance Method Summary collapse
- #call(method, *args) ⇒ Object
- #call2(method, *args) ⇒ Object
- #do_rpc(xmlrpc) ⇒ Object
-
#initialize(stream, jid) ⇒ Client
constructor
- xmppstream stream
- Stream
- jid where you want to send the rpc requests to jid
- JID
-
rpcserver@jabberserver/ressource.
-
#method_missing(methodname, *args) ⇒ Object
automatically trys to find a method thanx to eric cestari :).
-
#multicall(*methods) ⇒ Object
- adds multi rpcalls to the query methods
-
[Array].
-
#multicall2(*methods) ⇒ Object
- generate a multicall methods
-
[Array].
Constructor Details
#initialize(stream, jid) ⇒ Client
xmppstream
- stream
- Stream
jid where you want to send the rpc requests to
- jid
- JID
-
rpcserver@jabberserver/ressource
28 29 30 31 32 33 34 |
# File 'lib/xmpp4r/rpc/helper/client.rb', line 28 def initialize(stream,jid) @jid = JID.new(jid) @my_jid = stream.jid @stream = stream @parser = nil @create = XMLRPC::Create.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methodname, *args) ⇒ Object
automatically trys to find a method thanx to eric cestari :)
39 40 41 |
# File 'lib/xmpp4r/rpc/helper/client.rb', line 39 def method_missing(methodname, *args) send("call", methodname,*args) end |
Instance Attribute Details
#my_jid ⇒ Object
Returns the value of attribute my_jid.
21 22 23 |
# File 'lib/xmpp4r/rpc/helper/client.rb', line 21 def my_jid @my_jid end |
Instance Method Details
#call(method, *args) ⇒ Object
44 45 46 47 48 49 50 51 |
# 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 |
#call2(method, *args) ⇒ Object
53 54 55 56 57 |
# 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 |
#do_rpc(xmlrpc) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# 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 |
#multicall(*methods) ⇒ Object
adds multi rpcalls to the query
- methods
- Array
62 63 64 65 66 67 68 69 |
# File 'lib/xmpp4r/rpc/helper/client.rb', line 62 def multicall(*methods) ok, params = multicall2(*methods) if ok params else raise params end end |
#multicall2(*methods) ⇒ Object
generate a multicall
- methods
- Array
74 75 76 |
# File 'lib/xmpp4r/rpc/helper/client.rb', line 74 def multicall2(*methods) gen_multicall(methods) end |