### Home Classes Methods

### In Files

- lib/xmpp4r/discovery/helper/responder.rb

### Parent

Object

### Methods

- ::new
- #add_feature
- #add_features
- #generate_caps
- #generate_item

### 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::Discovery::Responder

Responds to Service Discovery queries on a given node

Modify returned elements by these attributes:

- Responder#identities

- Responder#features (Responder#add_features is a short-cut accepting an Array of Strings, too)

- Responder#forms

- Responder#items

### Constants

CALLBACK_PRIORITY

### Attributes

features[RW]

Features returned on Discovery Info query,

Array of [Discovery::Feature]

forms[RW]

Forms returned on Discovery Info query (such as Software Information)

Array of [Dataforms::XData]

identities[RW]

Identities returned on Discovery Info query

Array of [Discovery::Identity]

items[RW]

Children returned on Discovery Item query

May contain other Discovery::Responder instances which will generate an item dynamically from their first identity

Array of [Discovery::Item] or [Discovery::Responder] (mixed)

my_jid[RW]

Set the JID this helper feels responsible for (default: nil, responsible for any JID)

node[R]

Service Discovery node this Responder is responsible for (will not answer queries for other nodes)

### Public Class Methods

new(stream, node=nil, identities=[], features=[], items=[]) click to toggle source

Initialize responder for a specific node

stream

Jabber::Stream

node

nil

  or [String]

    # File lib/xmpp4r/discovery/helper/responder.rb, line 64
    def initialize(stream, node=nil, identities=[], features=[], items=[])
      @stream = stream
      @my_jid = nil
      @node = node
      @identities = identities
      @features = []
      add_features(features)
      @forms = []
      @items = items

      @stream.add_iq_callback(CALLBACK_PRIORITY, self) do |iq|
        my_nodes = [@node, "#{@node}##{generate_ver}"]

        if iq.type == :get and
           iq.query.kind_of? IqQueryDiscoInfo and
           my_nodes.include?(iq.query.node)

          answer = iq.answer(false)
          answer.type = :result
          query = answer.add(IqQueryDiscoInfo.new)
          query.node = iq.query.node
          (@identities + @features + @forms).each do |element|
            query.add(element)
          end
          @stream.send(answer)

          true  # handled

        elsif iq.type == :get and
              iq.query.kind_of? IqQueryDiscoItems and
              my_nodes.include?(iq.query.node)

          answer = iq.answer(false)
          answer.type = :result
          query = answer.add(IqQueryDiscoItems.new)
          query.node = iq.query.node
          @items.each do |item|
            if item.kind_of? Responder
              query.add(item.generate_item)
            else
              query.add(item)
            end
          end
          @stream.send(answer)

          true  # handled

        else
          false # not handled
        end
      end
    end

### Public Instance Methods

add_feature(feature) click to toggle source

Add a feature

feature

Jabber::Discovery::Feature

  or [String]

    # File lib/xmpp4r/discovery/helper/responder.rb, line 120
    def add_feature(feature)
      if feature.kind_of? Feature
        @features << feature
      else
        @features << Feature.new(feature.to_s)
      end
    end

add_features(features) click to toggle source

Add a series of features

features | Array of [Jabber::Discovery::Feature] or [String]

    # File lib/xmpp4r/discovery/helper/responder.rb, line 131
    def add_features(features)
      features.each { |feature|
        add_feature(feature)
      }
    end

generate_caps() click to toggle source

Generate a XEP-0115: Entity Capabilities <c/> element for inclusion in Presence stanzas. This enables efficient caching of Service Discovery information.

    # File lib/xmpp4r/discovery/helper/responder.rb, line 141
    def generate_caps
      Caps::C.new(@node, generate_ver)
    end

generate_item() click to toggle source

Generate an item for inclusion in items discovery in other responders

return

Discovery::Item

  or nil

    # File lib/xmpp4r/discovery/helper/responder.rb, line 149
    def generate_item
      i = @identities.first
      if i
        Item.new(@my_jid || @stream.jid, i.iname, @node)
      else
        nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.