Skip to content

Instantly share code, notes, and snippets.

@phuesler
Created November 7, 2011 22:31
Show Gist options
  • Save phuesler/1346420 to your computer and use it in GitHub Desktop.
Save phuesler/1346420 to your computer and use it in GitHub Desktop.
require 'em-websocket'
EM.run do
channel = EM::Channel.new
options = {:host => "0.0.0.0", :port => 8080}
EM::WebSocket.start(options) do |ws|
ws.onopen do
sid = channel.subscribe{|msg| ws.send msg}
end
ws.onclose do
channel.unsubscribe(sid)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment