root class of all Jabber XML elements
Compose a response by doing the following:
Create a new XMPPStanza of the same subclass with the same element-name
Import xmppstanza if import is true
Swap 'to' and 'from'
Copy 'id'
Does not take care about the type
Attention: Be careful when answering to stanzas with
type == :error
- answering to an error may generate another
error on the other side, which could be leading to a ping-pong effect
quickly!
source
Copy attributes and children of source
answer stanza
# File lib/xmpp4r/xmppstanza.rb, line 30 def XMPPStanza.answer(xmppstanza, import=true) x = xmppstanza.class.new if import x.import(xmppstanza) end x.from = xmppstanza.to x.to = xmppstanza.from x.id = xmppstanza.id x end
Compose a response of this XMPPStanza (see ::answer)
New constructed stanza
# File lib/xmpp4r/xmppstanza.rb, line 51 def answer(import=true) XMPPStanza.answer(self, import) end
Return the first <error/>
child
# File lib/xmpp4r/xmppstanza.rb, line 43 def error first_element('error') end
get the from attribute
the element's from attribute
# File lib/xmpp4r/xmppstanza.rb, line 91 def from (a = attribute('from')).nil? ? a : JID.new(a.value) end
set the from attribute
the value from set
# File lib/xmpp4r/xmppstanza.rb, line 99 def from= (v) add_attribute('from', v ? v.to_s : nil) end
get the id attribute
the element's id attribute
# File lib/xmpp4r/xmppstanza.rb, line 116 def id (a = attribute('id')).nil? ? a : a.value end
set the id attribute
the value id set
# File lib/xmpp4r/xmppstanza.rb, line 124 def id= (v) add_attribute('id', v.to_s) end
Makes some changes to the structure of an XML element to help it respect the specification. For example, in a message, we should have <subject/> < <body/> < { rest of tags }
# File lib/xmpp4r/xmppstanza.rb, line 59 def normalize end
set the from attribute (chaining-friendly)
the value from set
# File lib/xmpp4r/xmppstanza.rb, line 107 def set_from(v) add_attribute('from', v ? v.to_s : nil) self end
set the id attribute (chaining-friendly)
the value id set
# File lib/xmpp4r/xmppstanza.rb, line 132 def set_id(v) add_attribute('id', v.to_s) self end
set the to attribute (chaining-friendly)
the value to set
# File lib/xmpp4r/xmppstanza.rb, line 82 def set_to(v) self.to = v self end
set the type attribute (chaining-friendly)
the value type set
# File lib/xmpp4r/xmppstanza.rb, line 157 def set_type(v) add_attribute('type', v) self end
get the to attribute
the element's to attribute
# File lib/xmpp4r/xmppstanza.rb, line 66 def to (a = attribute('to')).nil? ? a : JID.new(a.value) end
set the to attribute
the value to set
# File lib/xmpp4r/xmppstanza.rb, line 74 def to= (v) add_attribute('to', v ? v.to_s : nil) end
get the type attribute
the element's type attribute
# File lib/xmpp4r/xmppstanza.rb, line 141 def type (a = attribute('type')).nil? ? a : a.value end
set the type attribute
the value type set
# File lib/xmpp4r/xmppstanza.rb, line 149 def type= (v) add_attribute('type', v) end