Class: Angelo::Server

Inherits:
Reel::Server::HTTP
  • Object
show all
Extended by:
Forwardable
Includes:
Celluloid::Logger
Defined in:
lib/angelo/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, host = '127.0.0.1', port = 4567) ⇒ Server

Returns a new instance of Server.



12
13
14
15
16
17
# File 'lib/angelo/server.rb', line 12

def initialize base, host = '127.0.0.1', port = 4567
  @base = base
  info "Angelo #{VERSION}"
  info "listening on #{host}:#{port}"
  super host, port, &method(:on_connection)
end

Class Method Details

.define_task(name, &action) ⇒ Object



28
29
30
# File 'lib/angelo/server.rb', line 28

def self.define_task name, &action
  define_method name, &action
end

.remove_task(name) ⇒ Object



32
33
34
# File 'lib/angelo/server.rb', line 32

def self.remove_task name
  remove_method name
end

Instance Method Details

#on_connection(connection) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/angelo/server.rb', line 19

def on_connection connection
  # RubyProf.resume
  connection.each_request do |request|
    meth = request.websocket? ? :websocket : request.method.downcase.to_sym
    dispatch! meth, connection, request
  end
  # RubyProf.pause
end