Class: Ji2p::Server::HttpServer

Inherits:
Object
  • Object
show all
Defined in:
lib/ji2p/server/http_server.rb

Instance Method Summary collapse

Constructor Details

#initialize(application, socket) ⇒ HttpServer

Returns a new instance of HttpServer.



6
7
8
9
# File 'lib/ji2p/server/http_server.rb', line 6

def initialize(application, socket)
  @application = application
  @socket = socket
end

Instance Method Details

#monitorObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ji2p/server/http_server.rb', line 22

def monitor
  #selections, = IO.select(@sockets)
  #io, = selections
  io = @socket

  begin
    socket = io.accept
    http = Ji2p::Server::HTTP::new(socket, @application)
    http.handle
  ensure
    socket.close
  end
end

#runObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/ji2p/server/http_server.rb', line 11

def run
  loop do
    begin
      monitor
    rescue Interrupt
      Ji2p.logger.log("INTERRUPTED")
      return
    end
  end
end