Skip to content

Instantly share code, notes, and snippets.

@kenichi
Created March 18, 2016 09:56
Show Gist options
  • Save kenichi/6fb7989238bcdc3b3402 to your computer and use it in GitHub Desktop.
Save kenichi/6fb7989238bcdc3b3402 to your computer and use it in GitHub Desktop.
require 'angelo'
class BG < Angelo::Base
websocket '/' do |ws|
websockets << ws
end
end
class Worker
include Celluloid
def run
@n = 1
every 1 do
@n += 1
n = @n.to_s
BG.websockets.each {|ws| ws.write n}
end
end
end
Worker.new.async.run
BG.run!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment