Class: SnowmanIO::WebServer::ConnectionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/snowman-io/web_server.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, app) ⇒ ConnectionHandler

include Celluloid



11
12
13
14
15
16
17
18
# File 'lib/snowman-io/web_server.rb', line 11

def initialize(connection, app)
  @connection = connection
  @app = app
  # async.run
  run
rescue Reel::SocketError
  @connection.close
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/snowman-io/web_server.rb', line 20

def run
  @connection.each_request do |request|
    # TODO: support websockets
    if request.websocket?
      request.respond :bad_request, "WebSockets not supported"
    else
      route_request request
    end
  end
end