class Qpid::Proton::Event::EventBase

EventBase is the foundation for creating application-specific events.

@example

# SCENARIO: A continuation of the example in EventType.
#
#           An Event class is defined to handle receiving encrypted
#           data from a remote endpoint.

class EncryptedDataEvent < EventBase
  def initialize(message)
    super(EncryptedDataEvent, message,
          Qpid::Proton::Event::ENCRYPTED_RECV)
  end
end

# at another point, when encrypted data is received
msg = Qpid::Proton::Message.new
msg.decode(link.receive(link.pending))
if encrypted?(msg)
  collector.put(EncryptedDataEvent.new(msg)
end

@see EventType The EventType class for how ENCRYPTED_RECV was defined.

Attributes

class_name[R]

Returns the name for the class associated with this event.

context[R]

Returns the associated context object for the event.

type[R]

Returns the type of the event.

Public Class Methods

new(class_name, context, type) click to toggle source

Creates a new event with the specific #class_name and context of the specified type.

@param #class_name [String] The name of the class. @param context [Object] The event context. @param type [EventType] The event type.

# File lib/event/event_base.rb, line 75
def initialize(class_name, context, type)
  @class_name = class_name
  @context = context
  @type = type
end

Public Instance Methods

dispatch(handler) click to toggle source

Invokes the type-specific method on the provided handler.

@param handler [Object] The handler to be notified of this event.

# File lib/event/event_base.rb, line 85
def dispatch(handler)
  Qpid::Proton.dispatch(handler, @type.method, self)
end