Class: DripDrop::HTTPServerHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- DripDrop::HTTPServerHandler
- Defined in:
- lib/dripdrop/handlers/http_server.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#message_class ⇒ Object
readonly
Returns the value of attribute message_class.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#recv_cbak ⇒ Object
readonly
Returns the value of attribute recv_cbak.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, opts = {}) ⇒ HTTPServerHandler
constructor
A new instance of HTTPServerHandler.
- #on_receive(msg_format = :dripdrop_json, &block) ⇒ Object
- #on_recv(*args, &block) ⇒ Object
Methods inherited from BaseHandler
#handle_error, #on_error, #print_exception
Constructor Details
#initialize(uri, opts = {}) ⇒ HTTPServerHandler
Returns a new instance of HTTPServerHandler.
45 46 47 48 49 50 51 |
# File 'lib/dripdrop/handlers/http_server.rb', line 45 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. end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
43 44 45 |
# File 'lib/dripdrop/handlers/http_server.rb', line 43 def address @address end |
#message_class ⇒ Object (readonly)
Returns the value of attribute message_class.
43 44 45 |
# File 'lib/dripdrop/handlers/http_server.rb', line 43 def @message_class end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
43 44 45 |
# File 'lib/dripdrop/handlers/http_server.rb', line 43 def opts @opts end |
#recv_cbak ⇒ Object (readonly)
Returns the value of attribute recv_cbak.
43 44 45 |
# File 'lib/dripdrop/handlers/http_server.rb', line 43 def recv_cbak @recv_cbak end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
43 44 45 |
# File 'lib/dripdrop/handlers/http_server.rb', line 43 def uri @uri end |
Instance Method Details
#on_receive(msg_format = :dripdrop_json, &block) ⇒ Object
53 54 55 56 57 |
# File 'lib/dripdrop/handlers/http_server.rb', line 53 def on_receive(msg_format=:dripdrop_json,&block) @recv_cbak = block @conn = EM.start_server(@uri.host, @uri.port, HTTPEMServer, self) self end |
#on_recv(*args, &block) ⇒ Object
59 60 61 62 |
# File 'lib/dripdrop/handlers/http_server.rb', line 59 def on_recv(*args,&block) $stderr.write "DripDrop Warning :on_recv is deprecated in favor of :on_receive" on_receive(*args,&block) end |