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, #around_serve_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(state) ⇒ Object
Receive the Message payload from the HTTP Message body.
-
#_send_result(state) ⇒ Object
Send the Result payload in the HTTP Response body as application/binary.
- #prepare_server!(opts = { }) ⇒ Object
- #run_server! ⇒ Object
- #stop_server! ⇒ Object
Methods inherited from HTTP
#_receive_result, #_send_message, #client, #close, #message_uri
Methods inherited from ASIR::Transport
#_after_invoke_message, #_subclass_responsibility, #around_serve_message!, #initialize, #invoke_message!, #needs_message_identifier?, #needs_message_timestamp?, #receive_message, #receive_result, #send_message, #send_result, #serve_message!, #stop!, #with_force_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(state) ⇒ Object
Receive the Message payload from the HTTP Message body.
13 14 15 16 17 |
# File 'lib/asir/transport/webrick.rb', line 13 def state = state.in_stream state. = .body state. = end |
#_send_result(state) ⇒ Object
Send the Result payload in the HTTP Response body as application/binary.
20 21 22 23 24 |
# File 'lib/asir/transport/webrick.rb', line 20 def _send_result state http_result = state.out_stream http_result[CONTENT_TYPE] = APPLICATION_BINARY http_result.body = state.result_payload end |
#prepare_server!(opts = { }) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/asir/transport/webrick.rb', line 26 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 *Error::Unrecoverable.modules raise rescue ::Exception => exc raise Error, "Webrick Server #{uri.inspect}: #{exc.inspect}", exc.backtrace end |
#run_server! ⇒ Object
42 43 44 45 |
# File 'lib/asir/transport/webrick.rb', line 42 def run_server! @server.start self end |
#stop_server! ⇒ Object
47 48 49 50 |
# File 'lib/asir/transport/webrick.rb', line 47 def stop_server! @server.stop self end |