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
@return [Symbol] method name that this event will call in {#dispatch}
@return [Symbol] method name that this event will call in {#dispatch}
Public Class Methods
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
@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
@return [Connection, nil] the connection for this event
# File lib/core/event.rb, line 112 def connection() @connection ||= get(Connection, :connection); end
@return [Container, nil] container for this event
# File lib/core/event.rb, line 106 def container() @container ||= get(Container, :container); end
@return [Object] the event context object
# File lib/core/event.rb, line 103 def context; return @context ||= _context; end
@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
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
# File lib/core/event.rb, line 142 def inspect() "#{self.class}(#{method.inspect}, #{context.inspect})"; end
@return [Link, nil] link for this event
# File lib/core/event.rb, line 118 def link() @link ||= get(Link, :link); end
@return [Message, nil] message for this event
# File lib/core/event.rb, line 139 def message() @message ||= delivery.message if delivery; end
@return [Receiver, nil] receiver associated with this event
# File lib/core/event.rb, line 124 def receiver() link if link && link.receiver?; end
@return [Sender, nil] sender associated with this event
# File lib/core/event.rb, line 121 def sender() link if link && link.sender?; end
@return [Session, nil] session for this event
# File lib/core/event.rb, line 115 def session() @session ||= get(Session, :session); end
# File lib/core/event.rb, line 141 def to_s() "#{self.class}(#{method}, #{context})"; end
@return [Tracker, nil] delivery for this event
# File lib/core/event.rb, line 136 def tracker() @tracker ||= get(Tracker); end
@return [Transport, nil] transport for this event
# File lib/core/event.rb, line 109 def transport() @transport ||= get(Transport, :transport); end
Private Instance Methods
# 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 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