Skip to content

Instantly share code, notes, and snippets.

@blazeroot
Created December 17, 2013 22:16
Show Gist options
  • Select an option

  • Save blazeroot/8013594 to your computer and use it in GitHub Desktop.

Select an option

Save blazeroot/8013594 to your computer and use it in GitHub Desktop.
require 'webrick'
require 'pubnub'
server = WEBrick::HTTPServer.new :Port => 8000
msgs = []
error_callback = lambda { |envelope|
puts 'Got some ERROR!'
puts envelope.inspect
}
pubnub = Pubnub.new(:subscribe_key => :demo, :publish_key => :demo, :error_callback => error_callback)
pubnub.subscribe(:channel => :hello_world){ |envelope| msgs << envelope.msg }
server.mount_proc '/' do |req, res|
res.body = msgs.join("\n")
end
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment