### Home Classes Methods

### In Files

- lib/xmpp4r/xmppstanza.rb

### Parent

XMPPElement

### Methods

- ::answer
- #answer
- #error
- #from
- #from=
- #id
- #id=
- #normalize
- #set_from
- #set_id
- #set_to
- #set_type
- #to
- #to=
- #type
- #type=

### Files

- CHANGELOG
- COPYING
- LICENSE
- README.rdoc
- README_ruby19.txt

### Class/Module Index

Quicksearch

- Jabber
- Jabber::ArgumentError
- Jabber::Bytestreams
- Jabber::Bytestreams::IBB
- Jabber::Bytestreams::IBBInitiator
- Jabber::Bytestreams::IBBQueueItem
- Jabber::Bytestreams::IBBTarget
- Jabber::Bytestreams::IqQueryBytestreams
- Jabber::Bytestreams::IqSi
- Jabber::Bytestreams::IqSiFile
- Jabber::Bytestreams::IqSiFileRange
- Jabber::Bytestreams::SOCKS5Bytestreams
- Jabber::Bytestreams::SOCKS5BytestreamsInitiator
- Jabber::Bytestreams::SOCKS5BytestreamsPeer
- Jabber::Bytestreams::SOCKS5BytestreamsServer
- Jabber::Bytestreams::SOCKS5BytestreamsServerStreamHost
- Jabber::Bytestreams::SOCKS5BytestreamsTarget
- Jabber::Bytestreams::SOCKS5Socket
- Jabber::Bytestreams::StreamHost
- Jabber::Bytestreams::StreamHostUsed
- Jabber::Callback
- Jabber::CallbackList
- Jabber::Caps
- Jabber::Caps::C
- Jabber::Caps::Helper
- Jabber::Client
- Jabber::ClientAuthenticationFailure
- Jabber::Command
- Jabber::Command::IqCommand
- Jabber::Command::Responder
- Jabber::Component
- Jabber::ComponentAuthenticationFailure
- Jabber::Connection
- Jabber::Connection::SSLSocketUTF8
- Jabber::Dataforms
- Jabber::Dataforms::XData
- Jabber::Dataforms::XDataField
- Jabber::Dataforms::XDataInstructions
- Jabber::Dataforms::XDataReported
- Jabber::Dataforms::XDataTitle
- Jabber::Delay
- Jabber::Delay::XDelay
- Jabber::Discovery
- Jabber::Discovery::Feature
- Jabber::Discovery::Helper
- Jabber::Discovery::Identity
- Jabber::Discovery::IqQueryDiscoInfo
- Jabber::Discovery::IqQueryDiscoItems
- Jabber::Discovery::Item
- Jabber::Discovery::Responder
- Jabber::EntityTime
- Jabber::EntityTime::IqTime
- Jabber::EntityTime::Responder
- Jabber::ErrorResponse
- Jabber::FeatureNegotiation
- Jabber::FeatureNegotiation::IqFeature
- Jabber::FileTransfer
- Jabber::FileTransfer::FileSource
- Jabber::FileTransfer::Helper
- Jabber::FileTransfer::TransferSource
- Jabber::Framework
- Jabber::Framework::Base
- Jabber::Framework::Bot
- Jabber::HTTPBinding
- Jabber::HTTPBinding::Client
- Jabber::IdGenerator
- Jabber::InvalidChatState
- Jabber::Iq
- Jabber::IqQuery
- Jabber::JID
- Jabber::JabberError
- Jabber::LastActivity
- Jabber::LastActivity::Helper
- Jabber::LastActivity::IqQueryLastActivity
- Jabber::MUC
- Jabber::MUC::IqQueryMUCAdmin
- Jabber::MUC::IqQueryMUCAdminItem
- Jabber::MUC::IqQueryMUCOwner
- Jabber::MUC::MUCBrowser
- Jabber::MUC::MUCClient
- Jabber::MUC::SimpleMUCClient
- Jabber::MUC::UserItem
- Jabber::MUC::XMUC
- Jabber::MUC::XMUCUser
- Jabber::MUC::XMUCUserInvite
- Jabber::MUC::XMUCUserItem
- Jabber::Message
- Jabber::NoNameXmlnsRegistered
- Jabber::NotConnected
- Jabber::Observable
- Jabber::Observable::Contact
- Jabber::Observable::PubSub
- Jabber::Observable::PubSub::AlreadySet
- Jabber::Observable::PubSub::NoService
- Jabber::Observable::Subscriptions
- Jabber::Presence
- Jabber::PubSub
- Jabber::PubSub::Configuration
- Jabber::PubSub::Event
- Jabber::PubSub::EventItem
- Jabber::PubSub::EventItems
- Jabber::PubSub::IqPubSub
- Jabber::PubSub::IqPubSubOwner
- Jabber::PubSub::Item
- Jabber::PubSub::Items
- Jabber::PubSub::NodeBrowser
- Jabber::PubSub::NodeConfig
- Jabber::PubSub::NodeHelper
- Jabber::PubSub::OAuthPubSubStreamHelper
- Jabber::PubSub::OAuthServiceHelper
- Jabber::PubSub::OwnerNodeConfig
- Jabber::PubSub::Publish
- Jabber::PubSub::Retract
- Jabber::PubSub::ServiceHelper
- Jabber::PubSub::Subscription
- Jabber::PubSub::SubscriptionConfig
- Jabber::PubSub::Unsubscribe
- Jabber::RPC
- Jabber::RPC::Client
- Jabber::RPC::IqQueryRPC
- Jabber::RPC::Server
- Jabber::Reliable
- Jabber::Reliable::Connection
- Jabber::Reliable::Listener
- Jabber::Roster
- Jabber::Roster::Helper
- Jabber::Roster::Helper::RosterItem
- Jabber::Roster::IqQueryRoster
- Jabber::Roster::RosterItem
- Jabber::Roster::RosterX
- Jabber::Roster::RosterXItem
- Jabber::Roster::XRoster
- Jabber::Roster::XRosterItem
- Jabber::SASL
- Jabber::SASL::Anonymous
- Jabber::SASL::Base
- Jabber::SASL::DigestMD5
- Jabber::SASL::Plain
- Jabber::SOCKS5Error
- Jabber::Semaphore
- Jabber::ServerDisconnected
- Jabber::Stream
- Jabber::Stream::ThreadBlock
- Jabber::StreamParser
- Jabber::Test
- Jabber::Test::ListenerMocker
- Jabber::UserLocation
- Jabber::UserLocation::Helper
- Jabber::UserLocation::Location
- Jabber::UserTune
- Jabber::UserTune::Helper
- Jabber::UserTune::Tune
- Jabber::Vcard
- Jabber::Vcard::Helper
- Jabber::Vcard::IqVcard
- Jabber::Version
- Jabber::Version::IqQueryVersion
- Jabber::Version::Responder
- Jabber::Version::SimpleResponder
- Jabber::X
- Jabber::XHTML
- Jabber::XHTML::Body
- Jabber::XHTML::HTML
- Jabber::XMPPElement
- Jabber::XMPPStanza
- Jabber::XParent
- REXML
- REXML::Element
- REXML::IOSource
- XMLRPC
- XMLRPC::Create
- Base64
- ObservableThing
- QObserver
- ThreadStore

No matching classes.

# Jabber::XMPPStanza

root class of all Jabber XML elements

### Public Class Methods

answer(xmppstanza, import=true) click to toggle source

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!

xmppstanza

XMPPStanza

  source

import

true or false

  Copy attributes and children of source

result

XMPPStanza

  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

### Public Instance Methods

answer(import=true) click to toggle source

Compose a response of this XMPPStanza (see XMPPStanza.answer)

result

XMPPStanza

  New constructed stanza

    # File lib/xmpp4r/xmppstanza.rb, line 51
    def answer(import=true)
      XMPPStanza.answer(self, import)
    end

error() click to toggle source

Return the first `<error/>` child

    # File lib/xmpp4r/xmppstanza.rb, line 43
    def error
      first_element('error')
    end

from() click to toggle source

get the from attribute

return

String

  the element's from attribute

    # File lib/xmpp4r/xmppstanza.rb, line 91
    def from
      (a = attribute('from')).nil? ? a : JID.new(a.value)
    end

from=(v) click to toggle source

set the from attribute

v

String

  the value from set

    # File lib/xmpp4r/xmppstanza.rb, line 99
    def from= (v)
      add_attribute('from', v ? v.to_s : nil)
    end

id() click to toggle source

get the id attribute

return

String

  the element's id attribute

    # File lib/xmpp4r/xmppstanza.rb, line 116
    def id
      (a = attribute('id')).nil? ? a : a.value
    end

id=(v) click to toggle source

set the id attribute

v

String

  the value id set

    # File lib/xmpp4r/xmppstanza.rb, line 124
    def id= (v)
      add_attribute('id', v.to_s)
    end

normalize() click to toggle source

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_from(v) click to toggle source

set the from attribute (chaining-friendly)

v

String

  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_id(v) click to toggle source

set the id attribute (chaining-friendly)

v

String

  the value id set

    # File lib/xmpp4r/xmppstanza.rb, line 132
    def set_id(v)
      add_attribute('id', v.to_s)
      self
    end

set_to(v) click to toggle source

set the to attribute (chaining-friendly)

v

String

  the value to set

    # File lib/xmpp4r/xmppstanza.rb, line 82
    def set_to(v)
      self.to = v
      self
    end

set_type(v) click to toggle source

set the type attribute (chaining-friendly)

v

String

  the value type set

    # File lib/xmpp4r/xmppstanza.rb, line 157
    def set_type(v)
      add_attribute('type', v)
      self
    end

to() click to toggle source

get the to attribute

return

String

  the element's to attribute

    # File lib/xmpp4r/xmppstanza.rb, line 66
    def to
      (a = attribute('to')).nil? ? a : JID.new(a.value)
    end

to=(v) click to toggle source

set the to attribute

v

String

  the value to set

    # File lib/xmpp4r/xmppstanza.rb, line 74
    def to= (v)
      add_attribute('to', v ? v.to_s : nil)
    end

type() click to toggle source

get the type attribute

return

String

  the element's type attribute

    # File lib/xmpp4r/xmppstanza.rb, line 141
    def type
      (a = attribute('type')).nil? ? a : a.value
    end

type=(v) click to toggle source

set the type attribute

v

String

  the value type set

    # File lib/xmpp4r/xmppstanza.rb, line 149
    def type= (v)
      add_attribute('type', v)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.