Class | Jabber::IqQueryRoster |
In: |
lib/xmpp4r/iq/query/roster.rb
|
Parent: | IqQuery |
Class for handling roster updates
You must do ‘client.send(Iq.new_rosterget)’ or else you will have nothing to put in receive_iq()
You must require ‘xmpp4r/rosterquery’ to use this class as its functionality is not needed for a working XMPP implementation. This will make [IqQuery] convert all Queries with namespace ‘jabber:iq:roster’ to [IqQueryRoster]
This <query/> contains multiple <item/> children. See RosterItem.
Get roster item by JID
jid: | [JID] or [Nil] |
result: | [RosterItem] |
# File lib/xmpp4r/iq/query/roster.rb, line 59 59: def [](jid) 60: each { |item| 61: return(item) if item.jid == jid 62: } 63: nil 64: end
Iterate through all items
&block: | Yield for every [RosterItem] |
# File lib/xmpp4r/iq/query/roster.rb, line 48 48: def each(&block) 49: each_element { |item| 50: # XPath won't work here as it's missing a prefix... 51: yield(item) if item.kind_of?(RosterItem) 52: } 53: end
Output for "p"
JIDs of all contained [RosterItem] elements are joined with a comma
result: | [String] |
# File lib/xmpp4r/iq/query/roster.rb, line 95 95: def inspect 96: jids = to_a.collect { |item| item.jid.inspect } 97: jids.join(', ') 98: end
Update roster by <iq/> stanza (to be fed by an iq_callback)
iq: | [Iq] Containing new roster |
filter: | [Boolean] If false import non-roster-like results too |
# File lib/xmpp4r/iq/query/roster.rb, line 82 82: def receive_iq(iq, filter=true) 83: if filter && (((iq.type != :set) && (iq.type != :result)) || (iq.queryns != 'jabber:iq:roster')) 84: return 85: end 86: 87: import(iq.query) 88: end
Get all items
result: | [Array] of [RosterItem] |
# File lib/xmpp4r/iq/query/roster.rb, line 69 69: def to_a 70: a = [] 71: each { |item| 72: a.push(item) 73: } 74: a 75: end
Add an element to the roster
Converts <item/> elements to RosterItem
Previous RosterItems with the same JID will not be deleted!
# File lib/xmpp4r/iq/query/roster.rb, line 36 36: def typed_add(element) 37: if element.kind_of?(REXML::Element) && (element.name == 'item') 38: item = RosterItem::new.import(element) 39: super(item) 40: else 41: super(element) 42: end 43: end