Class: Pione::Notification::Recipient
- Inherits:
-
Object
- Object
- Pione::Notification::Recipient
- Defined in:
- lib/pione/notification/recipient.rb
Overview
Recipient is a wrapper for notification recipients. This wraps a command and notifies messages to it when a notification listener receives notifications. Recipients should be registerd to listner periodically because the listener forgets recipients after some minites. Note that Recipient
instance is registered to a listener after it is created immediately, so the listener is launched up to that time.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(front_uri, listener_uri) ⇒ Recipient
constructor
A new instance of Recipient.
-
#notify(message) ⇒ Object
Notify the message.
- #terminate ⇒ Object
Constructor Details
#initialize(front_uri, listener_uri) ⇒ Recipient
Returns a new instance of Recipient.
14 15 16 17 18 19 |
# File 'lib/pione/notification/recipient.rb', line 14 def initialize(front_uri, listener_uri) @listener_uri = listener_uri @front_uri = front_uri @__listener_thread__ = keep_connection @__connection__ = false end |
Instance Method Details
#notify(message) ⇒ Object
Notify the message. This is a non-blocking method.
22 23 24 25 26 27 |
# File 'lib/pione/notification/recipient.rb', line 22 def notify() name = ("receive_%s" % .type).downcase if respond_to?(name) __send__(name, ) end end |
#terminate ⇒ Object
29 30 31 32 |
# File 'lib/pione/notification/recipient.rb', line 29 def terminate @__listerner_thread__.terminate if @__listener_thread__.alive? disconnect end |