Last active
October 28, 2015 18:50
-
-
Save SergeiStruk/084fa44482c0a2f27727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config/initializers/websocket_handler.rb | |
EM.next_tick do | |
@channel = EM::Channel.new | |
#Simulate messages. | |
EM::PeriodicTimer.new(3) do | |
random_string = rand(100_000).to_s | |
@channel.push random_string | |
end | |
EM::WebSocket.run(host: '0.0.0.0', port: 8080) do |ws| | |
ws.onmessage do |data| | |
... | |
end | |
ws.onclose do | |
... | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment