Class: DripDrop::HTTPEMServer

Inherits:
EM::Connection
  • Object
show all
Includes:
EM::HttpServer
Defined in:
lib/dripdrop/handlers/http_server.rb

Instance Method Summary collapse

Constructor Details

#initialize(dd_handler) ⇒ HTTPEMServer

Returns a new instance of HTTPEMServer.



21
22
23
# File 'lib/dripdrop/handlers/http_server.rb', line 21

def initialize(dd_handler)
  @dd_handler = dd_handler
end

Instance Method Details

#post_initObject



25
26
27
28
# File 'lib/dripdrop/handlers/http_server.rb', line 25

def post_init
  super
  no_environment_strings
end

#process_http_requestObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/dripdrop/handlers/http_server.rb', line 30

def process_http_request
  begin
    message     = @dd_handler.message_class.decode_json(@http_post_content)
    response    = EM::DelegatedHttpResponse.new(self)
    dd_response = HTTPServerHandlerResponse.new(response)
    @dd_handler.recv_cbak.call(message, dd_response) if @dd_handler.recv_cbak
  rescue StandardError => e
    handler_error(e)
  end
end