Sha256: 02caee602e80c7c8d48b40fc0ce38e27ceb83f8414152bb6c9c89ff207f1ceef

Contents?: true

Size: 1.71 KB

Versions: 48

Compression:

Stored size: 1.71 KB

Contents

module Blather
class Stanza
class PubSub

  # # PubSub Subscribe Stanza
  #
  # [XEP-0060 Section 6.1 - Subscribe to a Node](http://xmpp.org/extensions/xep-0060.html#subscriber-subscribe)
  #
  # @handler :pubsub_subscribe
  class Subscribe < PubSub
    register :pubsub_subscribe, :subscribe, self.registered_ns

    # Create a new subscription node
    #
    # @param [Blather::Stanza::Iq::VALID_TYPES] type the IQ stanza type
    # @param [String] host the host name to send the request to
    # @param [String] node the node to subscribe to
    # @param [Blather::JID, #to_s] jid see {#jid=}
    def self.new(type = :set, host = nil, node = nil, jid = nil)
      new_node = super(type, host)
      new_node.node = node
      new_node.jid = jid
      new_node
    end

    # Get the JID of the entity to subscribe
    #
    # @return [Blather::JID]
    def jid
      JID.new(subscribe[:jid])
    end

    # Set the JID of the entity to subscribe
    #
    # @param [Blather::JID, #to_s] jid
    def jid=(jid)
      subscribe[:jid] = jid
    end

    # Get the name of the node to subscribe to
    #
    # @return [String]
    def node
      subscribe[:node]
    end

    # Set the name of the node to subscribe to
    #
    # @param [String] node
    def node=(node)
      subscribe[:node] = node
    end

    # Get or create the actual subscribe node on the stanza
    #
    # @return [Blather::XMPPNode]
    def subscribe
      unless subscribe = pubsub.find_first('ns:subscribe', :ns => self.class.registered_ns)
        self.pubsub << (subscribe = XMPPNode.new('subscribe', self.document))
        subscribe.namespace = self.pubsub.namespace
      end
      subscribe
    end
  end  # Subscribe

end  # PubSub
end  # Stanza
end  # Blather

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
blather-0.4.14 lib/blather/stanza/pubsub/subscribe.rb
blather-0.4.13 lib/blather/stanza/pubsub/subscribe.rb
blather-0.4.12 lib/blather/stanza/pubsub/subscribe.rb
blather-0.4.11 lib/blather/stanza/pubsub/subscribe.rb
blather-0.4.10 lib/blather/stanza/pubsub/subscribe.rb
shingara-blather-0.4.9 lib/blather/stanza/pubsub/subscribe.rb
shingara-blather-0.4.8 lib/blather/stanza/pubsub/subscribe.rb
blather-0.4.8 lib/blather/stanza/pubsub/subscribe.rb