Sha256: d8100e9ccb68a9bc3b557cb6994ef6565d8010ec000e9f425ac5a5eaaf16cf0d
Contents?: true
Size: 972 Bytes
Versions: 1
Compression:
Stored size: 972 Bytes
Contents
require 'reel' require 'hara/base' 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 Hara.request_handler.call connection, request else warn "Connection not support" request.close end end end Hara.request_handler do |connection, request| info "#{request.remote_ip} request #{request.url}, not support" 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hara-0.1.0 | lib/hara/server.rb |