class Qpid::Proton::Event

@deprecated Only used with the deprecated {Handler::MessagingHandler} API.

Constants

EVENT_TYPE_NAMES
Event

@private

PROTON_METHOD_PREFIX
TYPE_METHODS

Attributes

method[RW]

@return [Symbol] method name that this event will call in {#dispatch}

type[RW]

@return [Symbol] method name that this event will call in {#dispatch}

Public Class Methods

new(impl, method=nil, context=nil) click to toggle source

Use Event.new(impl) to wrap a C event, or Event.new(nil, method, context) to create a pure-ruby event.

# File lib/core/event.rb, line 68
def initialize(impl, method=nil, context=nil)
  @impl, @method, @context = impl, method, context
  @method ||= TYPE_METHODS[Cproton.pn_event_type(@impl)] if @impl
end

Public Instance Methods

condition() click to toggle source

@return [Condition] Error condition associated with this event or nil if none.

# File lib/core/event.rb, line 145
def condition
  (context.remote_condition if context.respond_to? :remote_condition) ||
    (context.condition if context.respond_to? :condition)
end
connection() click to toggle source

@return [Connection, nil] the connection for this event

# File lib/core/event.rb, line 112
def connection() @connection ||= get(Connection, :connection); end
container() click to toggle source

@return [Container, nil] container for this event

# File lib/core/event.rb, line 106
def container() @container ||= get(Container, :container); end
context() click to toggle source

@return [Object] the event context object

# File lib/core/event.rb, line 103
def context; return @context ||= _context; end
delivery() click to toggle source

@return [Delivery, nil] delivery for this event

# File lib/core/event.rb, line 127
def delivery()
  @delivery ||= case context
                when Delivery then @delivery = @context
                  # deprecated: for backwards compat allow a Tracker to be treated as a Delivery
                when Tracker then @delivery = Delivery.new(context.impl)
                end
end
dispatch(handler) click to toggle source

Call handler.{#method}(self) if handler.respond_to? {#method} @return [Boolean] true if handler responded to the method, nil if not.

# File lib/core/event.rb, line 93
def dispatch(handler)
  (handler.__send__(@method, self); true) if handler.respond_to? @method
end
inspect() click to toggle source
# File lib/core/event.rb, line 142
def inspect() "#{self.class}(#{method.inspect}, #{context.inspect})"; end
message() click to toggle source

@return [Message, nil] message for this event

# File lib/core/event.rb, line 139
def message() @message ||= delivery.message if delivery; end
receiver() click to toggle source

@return [Receiver, nil] receiver associated with this event

# File lib/core/event.rb, line 124
def receiver() link if link && link.receiver?; end
sender() click to toggle source

@return [Sender, nil] sender associated with this event

# File lib/core/event.rb, line 121
def sender() link if link && link.sender?; end
session() click to toggle source

@return [Session, nil] session for this event

# File lib/core/event.rb, line 115
def session() @session ||= get(Session, :session); end
to_s() click to toggle source
# File lib/core/event.rb, line 141
def to_s() "#{self.class}(#{method}, #{context})"; end
tracker() click to toggle source

@return [Tracker, nil] delivery for this event

# File lib/core/event.rb, line 136
def tracker() @tracker ||= get(Tracker); end
transport() click to toggle source

@return [Transport, nil] transport for this event

# File lib/core/event.rb, line 109
def transport() @transport ||= get(Transport, :transport); end

Private Instance Methods

_context() click to toggle source
# File lib/core/event.rb, line 78
def _context
  x = Cproton.pn_event_context(@impl)
  case Cproton.pn_class_id(Cproton.pn_event_class(@impl))
  when Cproton::CID_pn_transport then Transport.wrap(Cproton.pn_cast_pn_transport(x))
  when Cproton::CID_pn_connection then Connection.wrap(Cproton.pn_cast_pn_connection(x))
  when Cproton::CID_pn_session then Session.wrap(Cproton.pn_cast_pn_session(x))
  when Cproton::CID_pn_link then Link.wrap(Cproton.pn_cast_pn_link(x))
  when Cproton::CID_pn_delivery then Delivery.wrap(Cproton.pn_cast_pn_delivery(x))
  end
end
get(clazz, method=nil) click to toggle source

Get the context if it is_a?(clazz), else call method on the context

# File lib/core/event.rb, line 74
def get(clazz, method=nil)
  (ctx = context).is_a?(clazz) ? ctx : ctx.__send__(method) rescue nil
end