Class: FireEagleJack

Inherits:
Object
  • Object
show all
Defined in:
lib/fire_hydrant/jacks/fire_eagle_jack.rb

Class Method Summary collapse

Class Method Details

.connect(switchboard, settings) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fire_hydrant/jacks/fire_eagle_jack.rb', line 2

def self.connect(switchboard, settings)
  switchboard.plug!(AutoAcceptJack, NotifyJack, PubSubJack)
  switchboard.hook(:location_update)

  switchboard.on_pubsub_event do |event|
    event.payload.each do |payload|
      payload.elements.each do |item|
        rsp = item.first_element("rsp")
        response = FireEagle::Response.parse(rsp.to_s)
        user = response.users[0]
        on(:location_update, user)
      end
    end
  end
end