added socket to initializers
This commit is contained in:
parent
3ce92c7c9d
commit
5b02597a05
1 changed files with 10 additions and 0 deletions
10
config/initializers/socket.rb
Normal file
10
config/initializers/socket.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
require 'em-websocket'
|
||||||
|
require 'eventmachine'
|
||||||
|
|
||||||
|
EM.next_tick {
|
||||||
|
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug => true) do |ws|
|
||||||
|
ws.onopen { ws.send "Hello Client!"}
|
||||||
|
ws.onmessage { |msg| ws.send "Pong: #{msg}" }
|
||||||
|
ws.onclose { puts "WebSocket closed" }
|
||||||
|
end
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue