Class: Jabber::RPC::Server

Inherits:
XMLRPC::BasicServer
  • Object
show all
Includes:
XMLRPC::ParseContentType, XMLRPC::ParserWriterChooseMixin
Defined in:
lib/xmpp4r/rpc/helper/server.rb

Overview

XMLRPC Server

Instance Method Summary collapse

Constructor Details

#initialize(stream, class_delim = ".") ⇒ Server

new - creates a new server



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/xmpp4r/rpc/helper/server.rb', line 24

def initialize(stream,class_delim=".")
  super(class_delim)
  @stream = stream
  @stream.add_iq_callback(120,"Helpers::RPCServer") { |iq|
    if iq.type == :set and iq.type != :result
      handle_iq(iq)
      true
    else
      false
    end
  }
end

Instance Method Details

#handle_iq(iq) ⇒ Object

handles incoming iqs

iq
Jabber::IQ
  • the jabber iq



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/xmpp4r/rpc/helper/server.rb', line 40

def handle_iq(iq)
  if iq.type == :set
    if iq.query.kind_of?(IqQueryRPC)
      data = iq.query
      response = IqQueryRPC.new
      data.elements.each { |rpc|
        if rpc
          response.typed_add(handle_rpc_requests(rpc))
        end
      }

      respiq = iq.answer(false)
      respiq.type = :result
      respiq.add(response)
      @stream.send(respiq)
    end
  end
end