A {ConnectionDriver} that feeds raw proton events to a handler.
@return [MessagingHandler] The handler dispatched to by {#process}
Combine an {IO} with a handler and provide a simplified way to run the driver via {#process}
@param io [IO] @param handler [Handler::MessagingHandler] to receive raw events in {#dispatch} and {#process}
# File lib/core/connection_driver.rb, line 169 def initialize(io, handler) super(io) @handler = handler @adapter = Handler::Adapter.adapt(handler) end
Dispatch all available raw proton events from {#event} to {#handler}
# File lib/core/connection_driver.rb, line 179 def dispatch() each_event do |e| case e.method # Events that affect the driver when :on_transport_tail_closed then close_read when :on_transport_head_closed then close_write end e.dispatch @adapter end end
Do {#read}, {#tick}, {#write} and {#dispatch} without blocking. @param [Time] now the current time @return [Time] Latest time to call {#process} again for scheduled events,
or nil if there are no scheduled events
# File lib/core/connection_driver.rb, line 193 def process(now=Time.now) read next_tick = tick(now) dispatch # Generate data for write write dispatch # Consume events generated by write return next_tick end