Sha256: f72d6a8a851c2aaabd79ffc31939e3686055ceb581c619e6ac015a446563b0d5

Contents?: true

Size: 1.08 KB

Versions: 35

Compression:

Stored size: 1.08 KB

Contents

module Blather
class Stanza
class Iq

  # # Ping Stanza
  #
  # [XEP-0199: XMPP Ping](http://xmpp.org/extensions/xep-0199.html)
  #
  # This is a base class for any Ping based Iq stanzas.
  #
  # @handler :ping
  class Ping < Iq
    # @private
    register :ping, :ping, 'urn:xmpp:ping'

    # Overrides the parent method to ensure a ping node is created
    #
    # @see Blather::Stanza::Iq.new
    def self.new(type = :get, to = nil, id = nil)
      node = super
      node.ping
      node
    end

    # Overrides the parent method to ensure the current ping node is destroyed
    #
    # @see Blather::Stanza::Iq#inherit
    def inherit(node)
      ping.remove
      super
    end

    # Ping node accessor
    # If a ping node exists it will be returned.
    # Otherwise a new node will be created and returned
    #
    # @return [Balather::XMPPNode]
    def ping
      p = find_first 'ns:ping', :ns => self.class.registered_ns

      unless p
        (self << (p = XMPPNode.new('ping', self.document)))
        p.namespace = self.class.registered_ns
      end
      p
    end
  end
end
end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
blather-2.0.0 lib/blather/stanza/iq/ping.rb
blather-1.2.0 lib/blather/stanza/iq/ping.rb
blather-1.1.4 lib/blather/stanza/iq/ping.rb
blather-1.1.3 lib/blather/stanza/iq/ping.rb
blather-1.1.2 lib/blather/stanza/iq/ping.rb
blather-1.1.1 lib/blather/stanza/iq/ping.rb
blather-1.1.0 lib/blather/stanza/iq/ping.rb
blather-1.0.0 lib/blather/stanza/iq/ping.rb
blather-0.8.8 lib/blather/stanza/iq/ping.rb
blather-0.8.7 lib/blather/stanza/iq/ping.rb
blather-0.8.6 lib/blather/stanza/iq/ping.rb
blather-0.8.5 lib/blather/stanza/iq/ping.rb
blather-0.8.4 lib/blather/stanza/iq/ping.rb
blather-0.8.3 lib/blather/stanza/iq/ping.rb
blather-0.8.2 lib/blather/stanza/iq/ping.rb
tp-blather-0.8.5 lib/blather/stanza/iq/ping.rb
tp-blather-0.8.4 lib/blather/stanza/iq/ping.rb
tp-blather-0.8.3 lib/blather/stanza/iq/ping.rb
tp-blather-0.8.2 lib/blather/stanza/iq/ping.rb
blather-0.8.1 lib/blather/stanza/iq/ping.rb