Commit e0159253 authored by John E. Vincent's avatar John E. Vincent

starting watcher agent framework.

parent fa4b0928
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
require 'rubygems'
require 'logger'
require 'optparse'
require 'em-hiredis'
require 'thin'
require 'noah'
EventMachine.run do
@logger = Logger.new(STDOUT)
# Passing messages...like a boss
@channel = EventMachine::Channel.new
r = EventMachine::Hiredis::Client.connect
r.psubscribe("//noah/*")
r.on(:pmessage) do |pattern, event, message|
@channel.push "[#{event}] [#{message}]"
@logger.debug("Publishing [#{event}]")
end
sub = @channel.subscribe {|msg|
puts msg
}
# EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 3001) do |ws|
# ws.onopen {
# sub = @channel.subscribe { |msg|
# ws.send msg
# }
#
# @channel.push "#{sub} connected and waiting...."
#
# ws.onmessage { |msg|
# @channel.push "<#{sub}>: #{msg}"
# }
#
# ws.onclose {
# @channel.unsubscribe(sub)
# }
# }
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment