Class Jabber::UserLocation::Helper
In: lib/xmpp4r/location/helper/helper.rb
Parent: PubSub::ServiceHelper

A Helper for XEP-0080 User Location

Use this helper to send a user‘s location, or receive them from a specified jid. Described at www.xmpp.org/extensions/xep-0080.html

For example: <pre> h = UserLocation::Helper( @client, ‘radio1@hug.hellomatty.com’ ) h.add_userlocation_callback do |location|

  puts "Now in: #{location.locality}"

end </pre>

Methods

Public Instance methods

Add a callback that will be invoked when a location is received from the jid specified when you constructed the Helper.

[Source]

    # File lib/xmpp4r/location/helper/helper.rb, line 46
46:       def add_userlocation_callback(prio = 200, ref = nil, &block)
47:         add_event_callback(prio, ref) do |event|
48:           location = event.first_element('items/item/location')
49:           if location
50:             block.call(location)
51:           end
52:         end
53:       end

Send out the current location.

location:[Jabber::UserLocation::Location] current_location

[Source]

    # File lib/xmpp4r/location/helper/helper.rb, line 29
29:       def current_location(location)
30:         item = Jabber::PubSub::Item.new()
31:         item.add(location)
32: 
33:         publish_item_to(NS_USERLOCATION, item)
34:       end

Use this method to indicate that you wish to stop publishing a location.

[Source]

    # File lib/xmpp4r/location/helper/helper.rb, line 39
39:       def stop_publishing
40:         current_location(Jabber::UserLocation::Location.new())
41:       end

[Validate]