Method: Jabber::Roster::Helper::RosterItem#add_presence
- Defined in:
- lib/xmpp4r/roster/helper/roster.rb
#add_presence(newpres) ⇒ Object
Add presence and sort presences (unless type is :unavailable or :error)
This overwrites previous stanzas with the same destination JID to keep track of resources. Presence stanzas with type == :unavailable
or type == :error
will be deleted as this indicates that this resource has gone offline.
If type == :error
and the presence’s origin has no specific resource the contact is treated completely offline.
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/xmpp4r/roster/helper/roster.rb', line 453 def add_presence(newpres) @presences_lock.synchronize { # Delete old presences with the same JID @presences.delete_if do |pres| pres.from == newpres.from or pres.from.resource.nil? end if newpres.type == :error and newpres.from.resource.nil? # Replace by single error presence @presences = [newpres] else # Add new presence @presences.push(newpres) end @presences.sort! } end |