class Blather::Stanza::Iq::Ping

# Ping Stanza

[XEP-0199: XMPP Ping](xmpp.org/extensions/xep-0199.html)

This is a base class for any Ping based Iq stanzas.

@handler :ping

Public Class Methods

new(type = :get, to = nil, id = nil) click to toggle source

Overrides the parent method to ensure a ping node is created

@see Blather::Stanza::Iq.new

Calls superclass method Blather::Stanza::Iq::new
# File lib/blather/stanza/iq/ping.rb, line 19
def self.new(type = :get, to = nil, id = nil)
  node = super
  node.ping
  node
end

Public Instance Methods

inherit(node) click to toggle source

Overrides the parent method to ensure the current ping node is destroyed

@see Blather::Stanza::Iq#inherit

Calls superclass method
# File lib/blather/stanza/iq/ping.rb, line 28
def inherit(node)
  ping.remove
  super
end
ping() click to toggle source

Ping node accessor If a ping node exists it will be returned. Otherwise a new node will be created and returned

@return [Balather::XMPPNode]

# File lib/blather/stanza/iq/ping.rb, line 38
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