Class: AgentXmpp::Xmpp::IqPubSub
- Inherits:
-
Element
- Object
- REXML::Element
- Element
- AgentXmpp::Xmpp::IqPubSub
- Defined in:
- lib/agent_xmpp/xmpp/iq_pubsub.rb
Overview
Class Method Summary collapse
-
.affiliations(pipe, to) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.create_node(pipe, to, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.subscribe(pipe, to, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.subscriptions(pipe, to) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
.unsubscribe(pipe, to, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Instance Method Summary collapse
-
#subscriptions ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
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
.affiliations(pipe, to) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/agent_xmpp/xmpp/iq_pubsub.rb', line 89 def affiliations(pipe, to) iq = Xmpp::Iq.new(:get, to) iq.pubsub = IqPubSub.new << REXML::Element.new('affiliations') Send(iq) do |r| if r.type == :result and r.kind_of?(Xmpp::Iq) pipe.broadcast_to_delegates(:on_pubsub_affiliations_result, pipe, r) elsif r.type.eql?(:error) pipe.broadcast_to_delegates(:on_pubsub_affiliations_error, pipe, r) end end end |
.create_node(pipe, to, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/agent_xmpp/xmpp/iq_pubsub.rb', line 19 def create_node(pipe, to, node) iq = Xmpp::Iq.new(:set, to) create = REXML::Element.new('create') create.add_attribute('node', node) iq.pubsub = IqPubSub.new << create configure = REXML::Element.new('configure') user_config = Publication.find_by_node(node) if user_config form = Xmpp::XData.new(:submit) form.add_field_with_value('FORM_TYPE', 'http://jabber.org/protocol/pubsub#node_config', :hidden) configure << AgentXmpp::DEFAULT_PUBSUB_CONFIG.inject(form) do |f, (var, val)| f.add_field_with_value("pubsub##{var.to_s}", user_config.send(var) || val) end end iq.pubsub << configure Send(iq) do |r| if r.type == :result and r.kind_of?(Xmpp::Iq) pipe.broadcast_to_delegates(:on_pubsub_create_node_result, pipe, r, node) elsif r.type.eql?(:error) pipe.broadcast_to_delegates(:on_pubsub_create_node_error, pipe, r, node) end end end |
.subscribe(pipe, to, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/agent_xmpp/xmpp/iq_pubsub.rb', line 57 def subscribe(pipe, to, node) iq = Xmpp::Iq.new(:set, to) subscribe = REXML::Element.new('subscribe') subscribe.add_attribute('node', node) subscribe.add_attribute('jid', AgentXmpp.jid..to_s) iq.pubsub = IqPubSub.new << subscribe Send(iq) do |r| if r.type == :result and r.kind_of?(Xmpp::Iq) pipe.broadcast_to_delegates(:on_pubsub_subscribe_result, pipe, r, node) elsif r.type.eql?(:error) pipe.broadcast_to_delegates(:on_pubsub_subscribe_error, pipe, r, node) end end end |
.subscriptions(pipe, to) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/agent_xmpp/xmpp/iq_pubsub.rb', line 44 def subscriptions(pipe, to) iq = Xmpp::Iq.new(:get, to) iq.pubsub = IqPubSub.new << REXML::Element.new('subscriptions') Send(iq) do |r| if r.type == :result and r.kind_of?(Xmpp::Iq) pipe.broadcast_to_delegates(:on_pubsub_subscriptions_result, pipe, r) elsif r.type.eql?(:error) pipe.broadcast_to_delegates(:on_pubsub_subscriptions_error, pipe, r) end end end |
.unsubscribe(pipe, to, node) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/agent_xmpp/xmpp/iq_pubsub.rb', line 73 def unsubscribe(pipe, to, node) iq = Xmpp::Iq.new(:set, to) unsubscribe = REXML::Element.new('unsubscribe') unsubscribe.add_attribute('node', node) unsubscribe.add_attribute('jid', AgentXmpp.jid..to_s) iq.pubsub = IqPubSub.new << unsubscribe Send(iq) do |r| if r.type == :result and r.kind_of?(Xmpp::Iq) pipe.broadcast_to_delegates(:on_pubsub_unsubscribe_result, pipe, r, node) elsif r.type.eql?(:error) pipe.broadcast_to_delegates(:on_pubsub_unsubscribe_error, pipe, r, node) end end end |
Instance Method Details
#subscriptions ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
105 106 107 |
# File 'lib/agent_xmpp/xmpp/iq_pubsub.rb', line 105 def subscriptions first_element('subscriptions').elements.to_a('subscription') end |