Class: ASIR::Transport::Webrick
- Inherits:
-
HTTP
- Object
- ASIR::Transport
- HTTP
- ASIR::Transport::Webrick
- Defined in:
- lib/asir/transport/webrick.rb
Overview
!SLIDE WEBrick Transport server.
Constant Summary
Constants inherited from HTTP
HTTP::APPLICATION_BINARY, HTTP::CONTENT_TYPE
Constants included from ASIR::ThreadVariable
ASIR::ThreadVariable::DEBUG, ASIR::ThreadVariable::EMPTY_HASH, ASIR::ThreadVariable::SETTER
Instance Attribute Summary
Attributes inherited from HTTP
Attributes inherited from ASIR::Transport
#after_invoke_message, #after_receive_message, #before_send_message, #coder_needs_result_message, #decoder, #encoder, #invoker, #message_count, #needs_message_identifier, #needs_message_timestamp, #on_exception, #on_result_exception, #one_way, #running, #verbose
Attributes included from Log
Instance Method Summary collapse
-
#_receive_message(http_message, additional_data) ⇒ Object
Receive the Message payload String from the HTTP Message object.
-
#_send_result(message, result, result_payload, http_result, message_state) ⇒ Object
Send the Result payload String in the HTTP Response object as application/binary.
- #prepare_server!(opts = { }) ⇒ Object
- #run_server! ⇒ Object
- #stop_server! ⇒ Object
Methods inherited from HTTP
#_receive_result, #_send_message, #client, #close
Methods inherited from ASIR::Transport
#_subclass_responsibility, #initialize, #invoke_message!, #needs_message_identifier?, #needs_message_timestamp?, #receive_message, #receive_result, #send_message, #send_result, #serve_message!, #stop!, #with_server_signals!
Methods included from Log
#_log, #_log_enabled=, #_log_enabled?, #_log_format, #_log_result, enabled, enabled=, included
Methods included from Initialization
Methods included from AdditionalData
#[], #[]=, #_additional_data, #additional_data, #additional_data!, #additional_data=, included
Methods included from Message::Delay
#relative_message_delay!, #wait_for_delay!
Methods included from ASIR::ThreadVariable
Constructor Details
This class inherits a constructor from ASIR::Transport
Instance Method Details
#_receive_message(http_message, additional_data) ⇒ Object
Receive the Message payload String from the HTTP Message object. Returns the original http_message as the message_state.
14 15 16 |
# File 'lib/asir/transport/webrick.rb', line 14 def , additional_data [ .body, ] end |
#_send_result(message, result, result_payload, http_result, message_state) ⇒ Object
Send the Result payload String in the HTTP Response object as application/binary.
19 20 21 22 |
# File 'lib/asir/transport/webrick.rb', line 19 def _send_result , result, result_payload, http_result, http_result[CONTENT_TYPE] = APPLICATION_BINARY http_result.body = result_payload end |
#prepare_server!(opts = { }) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/asir/transport/webrick.rb', line 24 def prepare_server! opts = { } u = URI.parse(uri) port = u.port path = u.path opts[:Port] ||= port @server = ::WEBrick::HTTPServer.new(opts) @server.mount_proc path, lambda { | rq, rs | rq, rs } self rescue ::Exception => exc raise Error, "Webrick Server #{uri.inspect}: #{exc.inspect}", exc.backtrace end |
#run_server! ⇒ Object
38 39 40 41 |
# File 'lib/asir/transport/webrick.rb', line 38 def run_server! @server.start self end |
#stop_server! ⇒ Object
43 44 45 46 |
# File 'lib/asir/transport/webrick.rb', line 43 def stop_server! @server.stop self end |