Class: PubSubJack

Inherits:
Object
  • Object
show all
Defined in:
lib/switchboard/jacks/pubsub.rb

Class Method Summary collapse

Class Method Details

.connect(switchboard, settings) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/switchboard/jacks/pubsub.rb', line 4

def self.connect(switchboard, settings)
  # TODO generalize this pattern for required settings
  unless settings["pubsub.server"]
    puts "A pubsub server must be specified."
    return false
  end

  switchboard.extend(Switchboard::Helpers::PubSubHelper)

  switchboard.on_startup do
    @pubsub = Jabber::PubSub::ServiceHelper.new(client, settings["pubsub.server"])

    @pubsub.add_event_callback do |event|
      on(:pubsub_event, event)
    end
  end
end