Class: Jabber::PubSub::NodeBrowser

Class | Jabber::PubSub::NodeBrowser
In: | lib/xmpp4r/pubsub/helper/nodebrowser.rb
Parent: | Object

### Methods

category get_info get_metadata items new nodes nodes_names type

### Public Class methods

new(stream)

Initialize a new NodeBrowser new(stream,pubsubservice)

stream: | [Jabber::Stream]

[Source]

        # File lib/xmpp4r/pubsub/helper/nodebrowser.rb, line 14
    14:       def initialize(stream)
    15:         @stream = stream
    16:       end

### Public Instance methods

category(jid,node)

get category of node

jid: | [Jabber::JID]
node: | [String]

[Source]

         # File lib/xmpp4r/pubsub/helper/nodebrowser.rb, line 123
    123:       def category(jid,node)
    124:         info = get_info(jid,node)
    125:         return info['category']
    126:       end

get_info(jid,node)

get disco info for a node

jid: | [Jabber::JID]
node: | [String]
return:: [Hash] with possible keys type:: [String] ,category:: [String],features:: [Array] of feature, nodeinformation: | [Jabber::XData]

check www.xmpp.org/extensions/xep-0060.html#entity for more infos

[Source]

         # File lib/xmpp4r/pubsub/helper/nodebrowser.rb, line 86
     86:       def get_info(jid,node)
     87:         iq = Iq.new(:get,jid)
     88:         iq.from = @stream.jid
     89:         discoinfo = Discovery::IqQueryDiscoInfo.new
     90:         discoinfo.node = node
     91:         iq.add(discoinfo)
     92:         info = {}
     93:         @stream.send_with_id(iq) do |answer|
     94:           identity = answer.query.identity
     95:           info['type'] = identity.type
     96:           info['category'] = identity.category
     97:           info['features'] = answer.query.features
     98:
     99:           answer.query.each_element('x') { |x|
    100:             info['nodeinformation'] = x
    101:           }
    102:         end
    103:         info
    104:       end

get_metadata(jid,node)

Alias for get_info

items(jid,node)

Retrieve the items from a node Throws an ServerError when receiving `<iq type=‘error’/>`

jid: | [Jabber::JID] Target entity (set only domain!)
node: | [String]
return: | [Array] of [Hash] with keys ‘name’ => [String] and ‘jid’ => [Jabber::JID]

[Source]

        # File lib/xmpp4r/pubsub/helper/nodebrowser.rb, line 64
    64:       def items(jid,node)
    65:         iq = Iq.new(:get,jid)
    66:         iq.from = @stream.jid
    67:         discoitems = Discovery::IqQueryDiscoItems.new
    68:         discoitems.node = node
    69:         iq.add(discoitems)
    70:         items = []
    71:         err = nil
    72:         @stream.send_with_id(iq) do |answer|
    73:           answer.query.each_element('item') { |item|
    74:             items.push( {'jid' => item.jid,'name' => item.iname } )
    75:           }
    76:         end
    77:         items
    78:       end

nodes(jid)

Retrieve the nodes Throws an ServerError when receiving `<iq type=‘error’/>`

jid: | [JID] Target entity (set only domain!)
return: | [Array] of [String] or [nil]

[Source]

        # File lib/xmpp4r/pubsub/helper/nodebrowser.rb, line 24
    24:       def nodes(jid)
    25:         iq = Iq.new(:get,jid)
    26:         iq.from = @stream.jid
    27:         iq.add(Discovery::IqQueryDiscoItems.new)
    28:         nodes = []
    29:         @stream.send_with_id(iq) do |answer|
    30:           answer.query.each_element('item') { |item|
    31:             nodes.push(item.node)
    32:           }
    33:         end
    34:         nodes
    35:       end

nodes_names(jid)

Retrieve the nodes with names Throws a ServerError when receiving `<iq type=‘error’/>`

jid: | [Jabber::JID] Target entity (set only domain!)
return: | [Array] of [Hash] with keys ‘node’ => [String] and ‘name’ => [String] or [nil]

[Source]

        # File lib/xmpp4r/pubsub/helper/nodebrowser.rb, line 43
    43:       def nodes_names(jid)
    44:         iq = Iq.new(:get,jid)
    45:         iq.from = @stream.jid
    46:         iq.add(Discovery::IqQueryDiscoItems.new)
    47:         nodes = []
    48:         @stream.send_with_id(iq) { |answer|
    49:           answer.query.each_element('item') do |item|
    50:             nodes.push( {'node' => item.node,'name' => item.iname } )
    51:           }
    52:         end
    53:         nodes
    54:       end

type(jid,node)

get type of node

jid: | [Jabber::JID]
node: | [String]

[Source]

         # File lib/xmpp4r/pubsub/helper/nodebrowser.rb, line 113
    113:       def type(jid,node)
    114:         info = get_info(jid,node)
    115:         return info['type']
    116:       end

[Validate]