require 'reel' module Hara class Server < Reel::Server include Celluloid::Logger def initialize host, port info "Server starting on #{host}:#{port}" super(host, port, &method(:on_connection)) end def on_connection(connection) while request = connection.request case request when Reel::WebSocket info "Received a WebSocket connection" handle_websocket request when Reel::Request warn "Not support normal connection" handle_request connection, request else warn "Not support normal connection" request.close end end end def handle_request connection, request request.close end def handle_websocket socket Hara::Application.new socket end def self.start host, port self.supervise_as :hara, host, port sleep end end end