Sha256: 510e512b87eaadded8ed36fc9f360ffe821386eeeb50d6984830fef2a9ce8c8e
Contents?: true
Size: 640 Bytes
Versions: 1
Compression:
Stored size: 640 Bytes
Contents
require 'em-websocket' require 'eventmachine' require 'hara/base' module Hara class Server class << self 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 {|close_info = {}| begin actor.async.set_close_info close_info actor.terminate! if actor.alive? rescue Celluloid::DeadActorError => e end } ws.onmessage { |msg| actor.async.process_msg msg } end } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hara-0.2.2 | lib/hara/server.rb |