Class: AgentXmpp::Xmpp::IqDiscoItems

Inherits:
IqQuery show all
Defined in:
lib/agent_xmpp/xmpp/iq_disco.rb

Overview


Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#<<, class_for_name_xmlns, #clone, import, #initialize, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=, xmpp_attribute, xmpp_child

Methods inherited from REXML::Element

#delete_elements, #first_element, #first_element_text, #import, import, #replace_element_text, #typed_add

Constructor Details

This class inherits a constructor from AgentXmpp::Xmpp::Element

Class Method Details

.get(pipe, to = nil, node = nil) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/agent_xmpp/xmpp/iq_disco.rb', line 19

def get(pipe, to=nil, node=nil)
  iq = Iq.new(:get, to)
  iq.query = new
  iq.query.node = node if node
  Send(iq) do |r|
    if (r.type == :result) && r.query.kind_of?(Xmpp::IqDiscoItems)
      pipe.broadcast_to_delegates(:did_receive_discoitems_result, pipe, r)
    elsif r.type.eql?(:error)
      pipe.broadcast_to_delegates(:did_receive_discoitems_error, pipe, r)
    end
  end
end

.result(pipe, request) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



33
34
35
36
37
38
# File 'lib/agent_xmpp/xmpp/iq_disco.rb', line 33

def result(pipe, request)
  iq = Xmpp::Iq.new(:result, request.from.to_s)
  iq.id = request.id unless request.id.nil?
  iq.query = new
  Send(iq)
end

.result_command_nodes(pipe, request) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



41
42
43
44
45
46
47
48
# File 'lib/agent_xmpp/xmpp/iq_disco.rb', line 41

def result_command_nodes(pipe, request)
  iq = Xmpp::Iq.new(:result, request.from.to_s)
  iq.id = request.id unless request.id.nil?
  iq.query = new
  iq.query.node = 'http://jabber.org/protocol/commands'
  iq.query.items = BaseController.command_nodes.map{|n| {:node => n, :name => n.humanize, :jid => AgentXmpp.jid.to_s}}
  Send(iq)
end

Instance Method Details

#itemsObject

.….….….….….….….….….….….….….….….….….….….….….….….….….….



54
55
56
# File 'lib/agent_xmpp/xmpp/iq_disco.rb', line 54

def items
  elements.to_a('item')
end

#items=(its) ⇒ Object

.….….….….….….….….….….….….….….….….….….….….….….….….….….



59
60
61
# File 'lib/agent_xmpp/xmpp/iq_disco.rb', line 59

def items=(its)
  its.each{|i| self << DiscoItem.new(i[:jid], i[:name], i[:node])}
end