Class | Jabber::XMLStanza |
In: |
lib/xmpp4r/xmlstanza.rb
|
Parent: | REXML::Element |
root class of all Jabber XML elements
Compose a response by doing the following:
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!
xmlstanza: | [XMLStanza] source |
import: | [true or false] Copy attributes and children of source |
result: | [XMLStanza] answer stanza |
# File lib/xmpp4r/xmlstanza.rb, line 29 29: def XMLStanza.answer(xmlstanza, import=true) 30: x = xmlstanza.class::new 31: if import 32: x.import(xmlstanza) 33: end 34: x.from = xmlstanza.to 35: x.to = xmlstanza.from 36: x.id = xmlstanza.id 37: x 38: end
Compose a response of this XMLStanza (see XMLStanza.answer)
result: | [XMLStanza] New constructed stanza |
# File lib/xmpp4r/xmlstanza.rb, line 63 63: def answer(import=true) 64: XMLStanza.answer(self, import) 65: end
Add a sub-element
Will be converted to [Error] if named "error"
element: | [REXML::Element] to add |
# File lib/xmpp4r/xmlstanza.rb, line 45 45: def typed_add(element) 46: if element.kind_of?(REXML::Element) && (element.name == 'error') 47: super(Error::import(element)) 48: else 49: super(element) 50: end 51: end