Class: Sumac::CallProcessor
- Includes:
- Emittable
- Defined in:
- lib/sumac/call_processor.rb
Instance Method Summary collapse
- #any_calls_processing? ⇒ Boolean
-
#initialize(connection) ⇒ CallProcessor
constructor
A new instance of CallProcessor.
- #receive(exchange) ⇒ Object
Constructor Details
#initialize(connection) ⇒ CallProcessor
Returns a new instance of CallProcessor.
5 6 7 8 9 |
# File 'lib/sumac/call_processor.rb', line 5 def initialize(connection) raise "argument 'connection' must be a Connection" unless connection.is_a?(Connection) @connection = connection @pending_calls = 0 end |
Instance Method Details
#any_calls_processing? ⇒ Boolean
11 12 13 |
# File 'lib/sumac/call_processor.rb', line 11 def any_calls_processing? @pending_calls > 0 end |
#receive(exchange) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/sumac/call_processor.rb', line 15 def receive(exchange) raise MessageError unless exchange.is_a?(Message::Exchange::CallRequest) raise MessageError unless @connection.at?([:active, :initiate_shutdown]) raise MessageError unless exchange.exposed_object.is_a?(ExposedObject) || exchange.exposed_object.is_a?(ExposedObjectChild) response = process(exchange) @connection.messenger.send(response) if response finished nil end |