Class: EventMachine::Protocols::TestConnection

Inherits:
Connection
  • Object
show all
Defined in:
lib/http_echo_server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.start(host, port) ⇒ Object



6
7
8
9
# File 'lib/http_echo_server.rb', line 6

def self.start(host, port)
  @@port = port
  EM.start_server(host, port, self)
end

Instance Method Details

#receive_data(data) ⇒ Object



11
12
13
14
15
# File 'lib/http_echo_server.rb', line 11

def receive_data(data)
  sleep $1.to_f if data =~ /^sleep (.*)/
  send_data("HTTP/1.1 200/OK\r\n\r\n#{data}")
  close_connection_after_writing
end