Class: AgentXmpp::Xmpp::IqPublish

Inherits:
Element show all
Defined in:
lib/agent_xmpp/xmpp/iq_pubsub.rb

Overview


Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#<<, class_for_name_xmlns, #clone, import, 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

#initialize(node = nil) ⇒ IqPublish

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



169
170
171
172
# File 'lib/agent_xmpp/xmpp/iq_pubsub.rb', line 169

def initialize(node=nil)
  super()
  self.node = node if node
end

Class Method Details

.set(pipe, args) ⇒ Object

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



151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/agent_xmpp/xmpp/iq_pubsub.rb', line 151

def set(pipe, args)
  iq = Xmpp::Iq.new(:set, args[:to])
  item =  Item.new << args[:payload]
  pub = IqPublish.new("#{AgentXmpp.user_pubsub_root}/#{args[:node]}") << item
  iq.pubsub = IqPubSub.new << pub
  Send(iq) do |r|
    if r.type == :result and r.kind_of?(Xmpp::Iq)
      pipe.broadcast_to_delegates(:did_receive_publish_result, pipe, r, args[:node])
    elsif r.type.eql?(:error)
      pipe.broadcast_to_delegates(:did_receive_publish_error, pipe, r, args[:node])
    end
  end     
end