class Qpid::Proton::HandlerDriver

A {ConnectionDriver} that feeds raw proton events to a handler.

Attributes

handler[R]

@return [MessagingHandler] The handler dispatched to by {#process}

Public Class Methods

new(io, handler) click to toggle source

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}

Calls superclass method Qpid::Proton::ConnectionDriver::new
# File lib/core/connection_driver.rb, line 177
def initialize(io, handler)
  super(io)
  @handler = handler
  @adapter = Handler::Adapter.adapt(handler)
end

Public Instance Methods

dispatch() click to toggle source

Dispatch all available raw proton events from {#event} to {#handler}

# File lib/core/connection_driver.rb, line 187
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
    when :on_transport_closed then @io.close rescue nil # Allow double-close
    end
    e.dispatch @adapter
  end
end
process(now=Time.now) click to toggle source

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 202
def process(now=Time.now)
  read
  dispatch
  next_tick = tick(now)
  dispatch
  write
  dispatch
  return next_tick
end