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

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

get category of node

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

[Source]

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

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:           answer.query.each_element('x') { |x|
 99:             info['nodeinformation'] = x
100:           }
101:         end
102:         info
103:       end
get_metadata(jid,node)

Alias for get_info

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

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

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) do |answer|
49:           answer.query.each_element('item') do |item|
50:             nodes.push( {'node' => item.node,'name' => item.iname } )
51:           end
52:         end
53:         nodes
54:       end

get type of node

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

[Source]

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

[Validate]