Class: Jabber::RPC::Client

Class | Jabber::RPC::Client
In: | lib/xmpp4r/rpc/helper/client.rb
Parent: | Object

XMLRPC Client

### Methods

call call2 do_rpc method_missing multicall multicall2 new

### Included Modules

XMLRPC::ParserWriterChooseMixin XMLRPC::ParseContentType

### Attributes

my_jid | [RW] |

### Public Class methods

new(stream,jid)

xmppstream

stream: | [Stream]

jid where you want to send the rpc requests to

jid: | [JID] rpcserver@jabberserver/ressource

[Source]

        # File lib/xmpp4r/rpc/helper/client.rb, line 28
    28:       def initialize(stream,jid)
    29:         @jid    = JID.new(jid)
    30:         @my_jid = stream.jid
    31:         @stream =  stream
    32:         @parser = nil
    33:         @create = XMLRPC::Create.new
    34:       end

### Public Instance methods

call(method, *args)

[Source]

        # File lib/xmpp4r/rpc/helper/client.rb, line 44
    44:       def call(method, *args)
    45:         ok, param = call2(method, *args)
    46:         if ok
    47:           param
    48:         else
    49:           raise param
    50:         end
    51:       end

call2(method, *args)

[Source]

        # File lib/xmpp4r/rpc/helper/client.rb, line 53
    53:       def call2(method, *args)
    54:         request = @create.methodCall(method, *args)
    55:         data = do_rpc(request)
    56:         parser().parseMethodResponse(data)
    57:       end

do_rpc(xmlrpc)

[Source]

        # File lib/xmpp4r/rpc/helper/client.rb, line 78
    78:       def do_rpc(xmlrpc)
    79:         iq = Iq.new(:set, @jid)
    80:         iq.from = @my_jid
    81:         iq.id = IdGenerator::generate_id
    82:         rpcquery = iq.add(IqQueryRPC.new)
    83:         rpcquery.typed_add(xmlrpc)
    84:
    85:         result = nil
    86:         @stream.send_with_id(iq) do |iqreply|
    87:           if iqreply.query.kind_of?(IqQueryRPC)
    88:             result = iqreply.query.to_s
    89:           end
    90:         end
    91:
    92:         result
    93:       end

method_missing(methodname, *args)

automatically trys to find a method thanx to eric cestari :)

[Source]

        # File lib/xmpp4r/rpc/helper/client.rb, line 39
    39:       def method_missing(methodname, *args)
    40:         send("call", methodname,*args)
    41:       end

multicall(*methods)

adds multi rpcalls to the query

methods: | [Array]

[Source]

        # File lib/xmpp4r/rpc/helper/client.rb, line 62
    62:       def multicall(*methods)
    63:         ok, params = multicall2(*methods)
    64:         if ok
    65:           params
    66:         else
    67:           raise params
    68:         end
    69:       end

multicall2(*methods)

generate a multicall

methods: | [Array]

[Source]

        # File lib/xmpp4r/rpc/helper/client.rb, line 74
    74:       def multicall2(*methods)
    75:         gen_multicall(methods)
    76:       end

[Validate]