Class: DripDrop::HTTPServerHandler

Inherits:
BaseHandler show all
Defined in:
lib/dripdrop/handlers/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHandler

#handle_error, #on_error, #print_exception

Constructor Details

#initialize(uri, opts = {}) ⇒ HTTPServerHandler

Returns a new instance of HTTPServerHandler.



46
47
48
49
50
51
52
# File 'lib/dripdrop/handlers/http.rb', line 46

def initialize(uri,opts={})
  @uri      = uri
  @uri_path = @uri.path.empty? ? '/' : @uri.path
  @address  = uri.to_s
  @opts     = opts
  @message_class = @opts[:message_class] || DripDrop.default_message_class
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



44
45
46
# File 'lib/dripdrop/handlers/http.rb', line 44

def address
  @address
end

#message_classObject (readonly)

Returns the value of attribute message_class.



44
45
46
# File 'lib/dripdrop/handlers/http.rb', line 44

def message_class
  @message_class
end

#optsObject (readonly)

Returns the value of attribute opts.



44
45
46
# File 'lib/dripdrop/handlers/http.rb', line 44

def opts
  @opts
end

#recv_cbakObject (readonly)

Returns the value of attribute recv_cbak.



44
45
46
# File 'lib/dripdrop/handlers/http.rb', line 44

def recv_cbak
  @recv_cbak
end

#uriObject (readonly)

Returns the value of attribute uri.



44
45
46
# File 'lib/dripdrop/handlers/http.rb', line 44

def uri
  @uri
end

Instance Method Details

#on_recv(msg_format = :dripdrop_json, &block) ⇒ Object



54
55
56
57
58
# File 'lib/dripdrop/handlers/http.rb', line 54

def on_recv(msg_format=:dripdrop_json,&block)
  @recv_cbak = block
  @conn = EM.start_server(@uri.host, @uri.port, HTTPEMServer, self)
  self
end