Sha256: 81b59698d3d860cb605ed6cba38ce02e8bc51db0b03238f54b56685e005a6e5d

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

# =XMPP4R - XMPP Library for Ruby
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
# Website::http://home.gna.org/xmpp4r/

require 'xmpp4r'
require 'xmpp4r/discovery'

module Jabber
  module Discovery
    ##
    # A Helper to manage service and item discovery.
    class Helper
      def initialize(client)
        @stream = client
      end

      ##
      # Service discovery on a JID.
      # jid:: [JID]
      # return:: [Jabber::Discovery::IqQueryDiscoInfo]
      def get_info_for(jid, node = nil)
        iq = Jabber::Iq.new(:get, jid)
        iq.from = @stream.jid
        disco = Jabber::Discovery::IqQueryDiscoInfo.new
        disco.node = node
        iq.add(disco)

        res = nil

        @stream.send_with_id(iq) { |reply|
          res = reply.query
        }

        res
      end

      ##
      # Item discovery on a JID.
      # jid:: [JID]
      # return:: [Jabber::Discovery::IqQueryDiscoItems]
      def get_items_for(jid, node = nil)
        iq = Jabber::Iq.new(:get, jid)
        iq.from = @stream.jid
        disco = Jabber::Discovery::IqQueryDiscoItems.new
        disco.node = node
        iq.add(disco)

        res = nil

        @stream.send_with_id(iq) { |reply|
          res = reply.query
        }

        res
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 7 rubygems

Version Path
brontes3d-xmpp4r-0.4 lib/xmpp4r/discovery/helper/helper.rb
ln-xmpp4r-0.5 lib/xmpp4r/discovery/helper/helper.rb
mojodna-xmpp4r-0.4.0.2 lib/xmpp4r/discovery/helper/helper.rb
mojodna-xmpp4r-0.4.0.3 lib/xmpp4r/discovery/helper/helper.rb
seanohalpin-xmpp4r-0.4.1 lib/xmpp4r/discovery/helper/helper.rb
xmpp4r-0.5.5 lib/xmpp4r/discovery/helper/helper.rb
gmcmillan-xmpp4r-0.6.2 lib/xmpp4r/discovery/helper/helper.rb
gmcmillan-xmpp4r-0.6.1 lib/xmpp4r/discovery/helper/helper.rb
gmcmillan-xmpp4r-0.6 lib/xmpp4r/discovery/helper/helper.rb
gmcmillan-xmpp4r-0.5 lib/xmpp4r/discovery/helper/helper.rb
mad-p-xmpp4r-0.6.3 lib/xmpp4r/discovery/helper/helper.rb
mad-p-xmpp4r-0.6.2 lib/xmpp4r/discovery/helper/helper.rb
mad-p-xmpp4r-0.6.1 lib/xmpp4r/discovery/helper/helper.rb
mad-p-xmpp4r-0.6.0 lib/xmpp4r/discovery/helper/helper.rb
xmpp4r-0.5 lib/xmpp4r/discovery/helper/helper.rb