Method: Compp::Sprinkler#initialize

Defined in:
lib/compp/sprinkler.rb

#initialize(opts = {}) ⇒ Sprinkler

Initialize a new Compp:Connection



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/compp/sprinkler.rb', line 13

def initialize(opts = {})
  if !@@xmpp_client
    # Right, we need to connect the xmpp client now
    @@xmpp_client = Blather::Client.setup(opts[:jid], opts[:password])
    @@channel = EM::Channel.new
    @@xmpp_client.register_handler(:message) do |m|
      @@channel.push(m.to_xml)
    end
    @@xmpp_client.connect
  end
  @@channel.subscribe{ |msg| 
    orbitize(msg)
  }
end