Class Jabber::RPC::Client
In: lib/xmpp4r/rpc/helper/client.rb
Parent: Object
Message Presence XMPPStanza Iq Singleton IdGenerator XMPPElement X IqQuery Error Connection Client Component Client Comparable JID RuntimeError AuthenticationFailure ErrorException NoNameXmlnsRegistered SOCKS5Error REXML::Element Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator XMPPElement StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite IqPubSub Items Subscription IqPubSubOwner Item Event Feature Item Identity XDataField XDataReported XDataTitle XDataInstructions IqVcard SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryMUCOwner IqQueryRPC IqQueryDiscoItems IqQueryDiscoInfo IBB IBBTarget IBBInitiator Responder SimpleResponder Iq IqCommand RosterXItem XRoster RosterX X XMUCUser XMUC XDelay XData XParent MUCClient SimpleMUCClient XMLRPC::ParserWriterChooseMixin Client Server XMLRPC::ParseContentType XMLRPC::BasicServer Base DigestMD5 Plain ServiceHelper NodeHelper FileSource CallbackList Callback Semaphore StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Responder Helper MUCBrowser NodeBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/xmppstanza.rb lib/xmpp4r/callbacks.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/client.rb lib/xmpp4r/stream.rb lib/xmpp4r/semaphore.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/xmppelement.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams XParent lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/command/iq/command.rb lib/xmpp4r/command/helper/responder.rb Command lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/iq/mucowner.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/rpc/helper/server.rb lib/xmpp4r/rpc/helper/client.rb lib/xmpp4r/rpc/iq/rpc.rb RPC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/pubsub/stanzas/subscription.rb lib/xmpp4r/pubsub/helper/servicehelper.rb lib/xmpp4r/pubsub/stanzas/item.rb lib/xmpp4r/pubsub/helper/nodehelper.rb lib/xmpp4r/pubsub/iq/pubsub.rb lib/xmpp4r/pubsub/stanzas/event.rb lib/xmpp4r/pubsub/helper/nodebrowser.rb lib/xmpp4r/pubsub/stanzas/items.rb PubSub lib/xmpp4r/httpbinding/client.rb HTTPBinding lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_80_0.png

Methods

call   call2   do_rpc   gen_multicall   multicall   multicall2   new  

Included Modules

XMLRPC::ParserWriterChooseMixin XMLRPC::ParseContentType

Attributes

my_jid  [RW] 

Public Class methods

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

[Source]

    # File lib/xmpp4r/rpc/helper/client.rb, line 36
36:       def call(method, *args)
37:         ok, param = call2(method, *args)
38:         if ok
39:           param
40:         else
41:           raise param
42:         end
43:       end

[Source]

    # File lib/xmpp4r/rpc/helper/client.rb, line 45
45:       def call2(method, *args)
46:         request = @create.methodCall(method, *args)
47:         data = do_rpc(request)
48:         parser().parseMethodResponse(data)
49:       end

[Source]

    # File lib/xmpp4r/rpc/helper/client.rb, line 70
70:       def do_rpc(xmlrpc)
71:         iq = Iq.new(:set, @jid)
72:         iq.from = @my_jid
73:         iq.id = IdGenerator::generate_id
74:         rpcquery = iq.add(IqQueryRPC.new)
75:         rpcquery.typed_add(xmlrpc)
76: 
77:         result = nil
78:         @stream.send_with_id(iq) { |iqreply|
79:           if iqreply.type == :result and iqreply.query.kind_of?(IqQueryRPC)
80:             result = iqreply.query.to_s
81:             true
82:           else
83:             false
84:           end
85:         }
86: 
87:         result
88:       end

adds multi rpcalls to the query

methods:[Array]

[Source]

    # File lib/xmpp4r/rpc/helper/client.rb, line 54
54:       def multicall(*methods)
55:         ok, params = multicall2(*methods)
56:         if ok
57:           params
58:         else
59:           raise params
60:         end
61:       end

generate a multicall

methods:[Array]

[Source]

    # File lib/xmpp4r/rpc/helper/client.rb, line 66
66:       def multicall2(*methods)
67:         gen_multicall(methods)
68:       end

Private Instance methods

[Source]

     # File lib/xmpp4r/rpc/helper/client.rb, line 92
 92:       def gen_multicall(methods=[])
 93:         ok, params = call2("system.multicall",
 94:           methods.collect { |m| {'methodName' => m[0], 'params' => m[1..-1]} }
 95:         )
 96: 
 97:         if ok
 98:           params = params.collect{ |param|
 99:             if param.is_a? Array
100:               param[0]
101:             elsif param.is_a? Hash
102:               XMLRPC::FaultException.new(param["faultCode"], param["faultString"])
103:             else
104:               raise "Wrong multicall return value"
105:             end
106:           }
107:         end
108: 
109:         return ok, params
110:       end

[Validate]