Class: Hara::Server
- Inherits:
-
Object
- Object
- Hara::Server
- Defined in:
- lib/hara/server.rb
Class Method Summary collapse
Class Method Details
.start(host, port) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hara/server.rb', line 8 def start host, port puts "Server starting on #{host}:#{port}" EM.epoll EM.run { EM::WebSocket.run(host: host, port: port) do |ws| actor = nil ws.onopen { |handshake| actor = Hara::Application.new handshake, ws } ws.onclose { begin actor.terminate! if actor.alive? rescue Celluloid::DeadActorError => e end } ws. { |msg| actor.async.process_msg msg } end } end |